function gfnsFilePathGet(sFile:
WideString):
WideString;
//Unicode対応ExtractFilePath。
var
i: Integer;
begin
Result := '';
if (sFile <> '')
then begin
for i := Length(sFile)
downto 1
do begin
if (sFile[i] = '\')
or (sFile[i] = '/')
then begin
Result := Copy(sFile, 1, i);
Break;
end else if (sFile[i] = ':')
then begin
Result := Copy(sFile, 1, i) + '\';
Break;
end;
end;
end;
end;
function gfnbFolderExists(sFolder:
WideString): Boolean;
//DirectoryExitsのWideString対応版。
var
lh_Handle: THandle;
lr_Info: TWin32FindDataW;
li_Len: Integer;
begin
Result := False;
if (sFolder <> '')
then begin
li_Len := Length(sFolder);
if (sFolder[li_Len] = '\')
then begin
SetLength(sFolder, li_Len-1);
end;
end;
FillChar(lr_Info, SizeOf(lr_Info), 0);
lh_Handle:= FindFirstFileW(PWideChar(sFolder), lr_Info);
try
if (lh_Handle<> INVALID_HANDLE_VALUE)
then begin
repeat
if (
WideString(lr_Info.cFileName) <> '.')
and (
WideString(lr_Info.cFileName) <> '..')
and ((lr_Info.dwFileAttributes and FILE_ATTRIBUTE_DIRECTORY) <> 0)
then begin
Result := True;
Break;
end;
until not(FindNextFileW(lh_Handle, lr_Info));
end;
finally
Windows.FindClose(lh_Handle);
end;
end;
function gfnbFileExists(sFile:
WideString): Boolean;
//Unicode対応FileExits。
//ワイルドカード対応版。
var
lh_Handle: THandle;
lr_Info: TWin32FindDataW;
begin
Result := False;
if (sFile <> '')
and (
gfnbFolderExists(
gfnsFilePathGet(sFile)))
then begin
FillChar(lr_Info, SizeOf(lr_Info), 0);
lh_Handle:= FindFirstFileW(PWideChar(sFile), lr_Info);
try
if (lh_Handle <> INVALID_HANDLE_VALUE)
then begin
repeat
if (
WideString(lr_Info.cFileName) <> '.')
and (
WideString(lr_Info.cFileName) <> '..')
and ((lr_Info.dwFileAttributes and FILE_ATTRIBUTE_DIRECTORY) = 0)
then begin
Result := True;
Break;
end;
until not(FindNextFileW(lh_Handle, lr_Info));
end;
finally
Windows.FindClose(lh_Handle);
end;
end;
end;