[Lazarus] GetAllFilesMask / AllFilesMask

Sven Barth pascaldragon at googlemail.com
Wed May 1 15:17:25 CEST 2013


On 01.05.2013 14:45, Bart wrote:
> On 5/1/13, J├╝rgen Hestermann <juergen.hestermann at gmx.de> wrote:
>
>
>> But wasn't the original problem that AllFilesMask was wrong on Windows?
>
> No.
> Supplying either '*.*' or '*' to FindFirst() function on Windows will
> correctly list all files.

And I've now checked why this is the case:

If you look at the implementation of FindFirstFileExW (which is in the 
end called by all other FindFirstFile* functions) in ReactOS ( 
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/client/file/find.c?revision=58833&view=markup 
) you'll see at line 822 the following code:

=== code begin ===

/* Change pattern: "*.*" --> "*" */
if (FilePattern.Length == 6 &&
     RtlCompareMemory(FilePattern.Buffer, L"*.*", 6) == 6)
{
     FilePattern.Length = 2;
}

=== code end ===

So this means it does not matter whether you pass '*.*' or '*' to 
FindFirstFile*, because the Win32 subsystem will adjust the mask anyway 
(FPC's FindFirst internally uses FindFirstFileA on Windows).

Regards,
Sven




More information about the Lazarus mailing list