【HSP3】ファイル名、ディレクトリ名として使える名前かチェックするモジュール

ファイル名もしくはディレクトリ名として使える名前かチェックするモジュールです。

ファイル名もしくはディレクトリ名として使える名前かチェックするモジュールです。

#module _FileNameCheck_
#uselib "Shlwapi.dll"
#func PathGetCharTypeA "PathGetCharTypeA" int
#func PathGetCharTypeW "PathGetCharTypeW" int
#define GCT_INVALID 0 // 使
#define GCT_LFNCHAR 1 // 使
#define GCT_SHORTCHAR 2 // 使
#define GCT_WILD 4 //
#define GCT_SEPARATOR 8 //
#defcfunc IsFileNamePath str _buftext
buftext = _buftext
sdim u_text, strlen(buftext)*2+2
cnvstow u_text, buftext
r = 0
repeat
if wpeek(u_text, cnt*2) == 0 : break
PathGetCharTypeW wpeek(u_text, cnt*2)
if stat == 0 | stat == 4 | stat == 8 : r = -1 : break
loop
return r
#defcfunc IsDirNamePath str _buftext
buftext = _buftext
sdim u_text, strlen(buftext)*2+2
cnvstow u_text, buftext
r = 0
repeat
if wpeek(u_text, cnt*2) == 0 : break
PathGetCharTypeW wpeek(u_text, cnt*2)
if stat == 0 | stat == 4 : r = -1 : break
loop
return r
#global
// 使 -1
mes IsFileNamePath("text.txt") ; OK
mes IsDirNamePath("C:\\test.txt") ; OK
mes IsFileNamePath("C:\\test.txt") ; \使NG
mes IsDirNamePath("C:\\test.txt") ; OK
mes IsFileNamePath("test?.txt") ; ?使NG
mes IsDirNamePath("C:\\test?.txt") ; ?使NG
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX