Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2004-01

small bug

2 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Johannes Berg

The windows version for DirectoryExists has a bug:

Function DirectoryExists (Const Directory : String) : Boolean;
var
  Handle: THandle;
  FindData: TWin32FindData;
begin
  Handle := FindFirstFile(Pchar(Directory), FindData);
  Result:=(Handle  INVALID_HANDLE_VALUE) and
          ((FindData.dwFileAttributes and FILE_ATTRIBUTE_DIRECTORY) = FILE_ATTRIBUTE_DIRECTORY)
  If Result then
    Windows.FindClose(Handle);
end;

It doesn't close the find handle if whatever it found wasn't a directory.

johannes

http://www.sipsolutions.de/ GnuPG key: http://www.sipsolutions.de/keys/JohannesBerg.asc Key-ID: 9AB78CA5 Johannes Berg Fingerprint = AD02 0176 4E29 C137 1DF6 08D2 FC44 CF86 9AB7 8CA5

Reply by email

Unknown author
to Johannes Berg
Johannes Berg wrote 15 lines
The windows version for DirectoryExists has a bug: Function DirectoryExists (Const Directory : String) : Boolean; var Handle: THandle; FindData: TWin32FindData; begin Handle := FindFirstFile(Pchar(Directory), FindData); Result:=(Handle INVALID_HANDLE_VALUE) and ((FindData.dwFileAttributes and FILE_ATTRIBUTE_DIRECTORY) = FILE_ATTRIBUTE_DIRECTORY) If Result then Windows.FindClose(Handle); end; It doesn't close the find handle if whatever it found wasn't a directory.

Thanks, fixed.

Michael.

Reply by email