From 5a90cac874ddce946f2212aca7e5c923f86c2f6d Mon Sep 17 00:00:00 2001 From: tobigun Date: Thu, 23 Jul 2009 15:12:30 +0000 Subject: changed implementation of WideFileExists() to improve performance git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/branches/experimental@1871 b956fd51-792f-4845-bead-9b4dfca2ff2c --- unicode/src/lib/TntUnicodeControls/TntSysUtils.pas | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) (limited to 'unicode') diff --git a/unicode/src/lib/TntUnicodeControls/TntSysUtils.pas b/unicode/src/lib/TntUnicodeControls/TntSysUtils.pas index 17084f35..0b0f5c5e 100644 --- a/unicode/src/lib/TntUnicodeControls/TntSysUtils.pas +++ b/unicode/src/lib/TntUnicodeControls/TntSysUtils.pas @@ -1041,22 +1041,15 @@ var Code: Cardinal; begin Code := WideFileGetAttr(Name); - Result := (Code <> INVALID_FILE_ATTRIBUTES) and (FILE_ATTRIBUTE_DIRECTORY and Code <> 0); + Result := (Code <> INVALID_FILE_ATTRIBUTES) and ((FILE_ATTRIBUTE_DIRECTORY and Code) <> 0); end; function WideFileExists(const Name: WideString): Boolean; var - Handle: THandle; - FindData: TWin32FindDataW; + Code: Cardinal; begin - Result := False; - Handle := Tnt_FindFirstFileW(PWideChar(Name), FindData); - if Handle <> INVALID_HANDLE_VALUE then - begin - Windows.FindClose(Handle); - if (FindData.dwFileAttributes and FILE_ATTRIBUTE_DIRECTORY) = 0 then - Result := True; - end; + Code := WideFileGetAttr(Name); + Result := (Code <> INVALID_FILE_ATTRIBUTES) and ((FILE_ATTRIBUTE_DIRECTORY and Code) = 0); end; function WideFileGetAttr(const FileName: WideString): Cardinal; -- cgit v1.2.3