While I was testing simple IO functions, I had a curious behavior for the
FindFirstFile function that is not referenced as a bug into the MSDN doc. So
be careful if, like me, you use this function under W2K. I didn't check that
the problem also occurs under 9x, Me, NT, XP... but I would't be surprised to
have the same behavior.
I was using it to retrieve all the files with a given extension. I called it
with :
HANDLE hFind = FindFirstFile("*.cpp", &wfd);
The problem is that such a call retrieves also files like "*.cpp2",
"*.cpp_", "*.cppcpp" and so on. It seems to be a bug since the problem occurs
only with 3 characters file extensions. If I try the following call :
HANDLE hFind = FindFirstFile("*.h", &wfd);
it works fine and I have only the .h files, not the .hpp files, for example.
So it's necessary to make an additionnal checking on the name ot the files
returned by FindFirstFile/FindNextFile to remove the unmatching files.
Regards
nono
d
--
Please do not send e-mail directly to this alias. this alias is for
newsgroup purposes only.
This posting is provided "AS IS" with no warranties, and confers no rights.
"nocturnozor" <noctu...@discussions.microsoft.com> wrote in message
news:78B1E753-26E1-49E1...@microsoft.com...
nono
This is not a bug . It is by design. It was a kludge put in to support
old programs which were not designed to handle long file extensions.
--
-GJC [MS Windows SDK MVP]
-Software Consultant (Embedded systems and Real Time Controls)
- http://www.mvps.org/ArcaneIncantations/consulting.htm
-gcha...@mvps.org
They should expect it. It's been this way since the introduction of
long file names.
> "qfel" <RemIt...@aster.pl> wrote in message
> news:cg2q4p$26rn$1...@mamut.aster.pl...
>
>>> This is not a bug . It is by design. It was a kludge put in to
>>
>>support
Thanks nocturnozor, this is very useful information.
I agree with qfel that this behaviour is a bug especially if it is not
documented.
If the application calls FindFirstFile from KERNEL32.DLL, this app has
been written as 32-bit; As far as I remember long filenames were
introduced in MS OSes in Win95 i.e. together with Win32.
The 8.3 compatibility code should have been implemented in INT21
emulation layer.
>>
>>>old programs which were not designed to handle long file extensions.
>>
>>Then it's incompatible with new programs because it works not the way they
>>expect it to work.
>
>
> They should expect it. It's been this way since the introduction of
> long file names.
>
Gary, I am a long time Win32 programmer and I did not know that and
would not expect it; since I always use FindFirstFile("*", ...) and do
search elsewhere.
This is an obscure but known behavior. See for example
and the rest of the thread from that message.
I don't have time to check it at the moment, but I recall that if you give
it a path of \\?\full_path_to_directory\wildcard that the function will
behave like you want... but don't quote me on that without testing it first!
-cd