[fpc-devel] Patch to bug 4356

Luiz Américo pascalive at bol.com.br
Sat Oct 8 15:19:12 CEST 2005


This patch resolves the bug 4356.

The problem is with the FindFirstFile behavior:

(Excerpt from win32 SDK)

"You cannot use root directories as the lpFileName input string for 
FindFirstFile, with or without a trailing backslash. To examine files in 
a root directory, use something like "C:\*" and step through the 
directory with FindNextFile. To get the attributes of a root directory, 
use GetFileAttributes. Prepending the string "\\?\" does not allow 
access to the root directory."

[..]

"To examine any directory other than a root directory, use an 
appropriate path to that directory, with no trailing backslash. For 
example, an argument of "C:\windows" will return information about the 
directory "C:\windows", not about any directory or file in "C:\windows". 
An attempt to open a search with a trailing backslash will always fail."




Here are the tests i did:

//Absolutes
   WriteLn('DirectoryExists(''C''): ',DirectoryExists('C'));
   WriteLn('DirectoryExists(''C:''): ',DirectoryExists('C:'));
   WriteLn('DirectoryExists(''C:\''): ',DirectoryExists('C:\'));
   WriteLn('DirectoryExists(''C:\AUTOEXEC.BAT''): 
',DirectoryExists('C:\AUTOEXEC.BAT'));
   WriteLn('DirectoryExists(''C:\thisdoesnotexists''): 
',DirectoryExists('C:\thisdoesnotexists'));
   WriteLn('DirectoryExists(''C:\Windows''): 
',DirectoryExists('C:\Windows'));
   WriteLn('DirectoryExists(''C:\Windows\''): 
',DirectoryExists('C:\Windows\'));
   //Relatives
   WriteLn('DirectoryExists(''thisexists''): 
',DirectoryExists('thisexists'));
   WriteLn('DirectoryExists(''thisdoesnotexists''): 
',DirectoryExists('thisdoesnotexists'));
   WriteLn('DirectoryExists(''..\thisexists''): 
',DirectoryExists('..\thisexists'));
   WriteLn('DirectoryExists(''..\thisdoesnotexists''): 
',DirectoryExists('..\thisdoesnotexists'));

Luiz Américo
-------------- next part --------------
A non-text attachment was scrubbed...
Name: direxists.zip
Type: application/zip
Size: 517 bytes
Desc: not available
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20051008/a453be91/attachment.zip>


More information about the fpc-devel mailing list