-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutil.hsp
96 lines (86 loc) · 2.11 KB
/
util.hsp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#ifndef util_hsp_included
#define util_hsp_included
#module
/*
HSP3ランタイムからそのバージョンを取得する
返り値
ランタイムのバージョン文字列
*/
#defcfunc get_runtime_ver
sdim stdout, 2000
sdim ln, 2000
buf = "#runtime \"hsp3cl\"\nmes strf(\"%4x\",hspver)\nend 1"
notesel buf
notesave "__hspver.hsp"
hsc_ini@ "__hspver.hsp"
hsc_compath@ dir_exe + "\\common\\"
hsc_comp@ 1, 0, 0
hsc_getmes@ stdout
hsc_bye@
hsp3cl_runtime = dir_exe + "\\hsp3cl.exe " + "__hspver.ax"
stdout = ""
ln = ""
pipeexec@ stdout, hsp3cl_runtime
repeat
pipeget@ ln
if stat == 0 : break
wait 1
loop
delete "__hspver.hsp"
delete "__hspver.ax"
return stdout
/*
引数で渡されたランタイム名が有効であるかを判定する
引数
runtime_name: ランタイム名
返り値
ruintime_nameが有効であればtrue
*/
#defcfunc is_valid_runtime_name str runtime_name
if runtime_name == "hsp3" : return 1
retval = 0
now_cwd = dir_cur
chdir dir_exe + "\\runtime"
dirlist runtime_file_buf, "*.hrt", 0
notesel runtime_file_buf
repeat notemax
noteget file_name, cnt
if runtime_name == getpath(file_name, 1) {
retval = 1
break
}
loop
chdir now_cwd
return retval
/*
引数で渡されたパスがフォルダであるかどうかを判定する
引数
path: パス文字列
返り値
pathがフォルダであればtrue
*/
#defcfunc exist_dir str path
dw_attrib = GetFileAttributes(path)
return dw_attrib != -1 && (dw_attrib & 0x00000010) != 0
/*
引数で渡されたパスが絶対パスであるとき、非ゼロを返す
*/
#defcfunc is_absolute_path str path
return PathIsRelativeA(path) == 0
/*
引数で渡されたパスが相対パスであるとき、非ゼロを返す
*/
#defcfunc is_relative_path str path
return PathIsRelativeA(path)
/*
渡された絶対パスからドライブ文字(C:\)を取り除いた文字列を返す
*/
#defcfunc none_drive_letter str fullpath
return replace(fullpath, "[A-Z]:\\\\", "")
#defcfunc get_absolute_path str path, local full_path
offset = 0
sdim full_path, 260
GetFullPathNameA path, 260, varptr(full_path), offset
return full_path
#global
#endif