;============================================================ ; iron_path.hsp — パス操作ユーティリティ ;============================================================ #ifndef __iron_path_hsp__ #define __iron_path_hsp__ #module iron_path #uselib "shlwapi.dll" #cfunc _PathCombineA "PathCombineW" var, wstr, wstr #cfunc _PathFindExtensionA "PathFindExtensionA" str #cfunc _PathFindFileNameA "PathFindFileNameA" str #cfunc _PathRemoveFileSpecA "PathRemoveFileSpecA" var #cfunc _PathIsRelativeA "PathIsRelativeW" wstr #cfunc _PathFileExistsA "PathFileExistsW" wstr #uselib "kernel32.dll" #cfunc _GetTempPathW2 "GetTempPathW" int, var #cfunc _WC2MB2 "WideCharToMultiByte" int, int, var, int, var, int, int, int ; パス結合 #defcfunc path_combine str dir, str file, local wbuf, local ubuf sdim wbuf, 520 _r = _PathCombineA(wbuf, dir, file) ; PathCombineW outputs UTF-16 sdim ubuf, 520 _r = _WC2MB2(65001, 0, wbuf, -1, ubuf, 520, 0, 0) return ubuf ; 拡張子取得 (.txt 等) #defcfunc path_ext str path return getpath(path, 2) ; ファイル名取得 #defcfunc path_filename str path return getpath(path, 8) ; ディレクトリ取得 #defcfunc path_dir str path return getpath(path, 32) ; 拡張子なしファイル名 #defcfunc path_stem str path, local f, local p f = getpath(path, 8) p = instr(f, 0, ".") if p < 0 : return f return strmid(f, 0, p) ; パスが存在するか #defcfunc path_exists str path return _PathFileExistsA(path) ; 相対パスか #defcfunc path_is_relative str path return _PathIsRelativeA(path) ; 一時フォルダ #defcfunc path_temp local wbuf2, local ubuf2 sdim wbuf2, 520 _r = _GetTempPathW2(260, wbuf2) sdim ubuf2, 520 _r = _WC2MB2(65001, 0, wbuf2, -1, ubuf2, 520, 0, 0) return ubuf2 #global #endif