Your test doesn't make much sense. The call to FindClose should be done after you check the result of GetLastError, since FindClose <should> change the last error to ERROR_SUCCESS if the close operation was successful.
From your test results, it seems that the FindClose implementation on the
version of windows you're using doesn't seem to do this. I would consider this a bug in windows, not a bug in Wine. If a programmer relies on this behavior, it's their fault, not MS's or Wine's fault that their code does not work.
----- Original Message ----- From: "Alex Pasadyn" ajp@mail.utexas.edu To: wine-devel@winehq.org Sent: Saturday, August 16, 2003 11:55 AM Subject: GetLastError strangeness with FindClose
Hi all, I observed a program that was bailing out with an absolutely baffling error message. I have traced it to its cause, but now I'm stuck. Basically, it was telling me that it had an error in FindNextFile of "success". I did a relay trace and found out that it was calling FindFirstFile, FindNextFile a bunch of times, FindClose, and then GetLastError.
So, I put together a little test:
#include <windows.h> #include <stdio.h>
WIN32_FIND_DATA fd; HANDLE h;
int main(int argc, char *argv[]) {
h = FindFirstFile("*", &fd); if (h == INVALID_HANDLE_VALUE) { printf("Error finding first file: %d\n", GetLastError()); return 1; } printf("found file: %s\n", fd.cFileName); while (FindNextFile(h, &fd)) { printf("found file: %s\n", fd.cFileName); } FindClose(h); switch (GetLastError()) { case ERROR_NO_MORE_FILES: printf("all done!\n"); return 0; default: printf("Error finding next file: %d\n", GetLastError()); return 1; } return 1;
}
Now, on Windows, the output is: G:\testfnf>testfnf found file: . found file: .. found file: testfnf.cpp found file: testfnf.exe all done!
And with Wine the output is: [ajp@toaster testfnf]$ ~/wine/wine testfnf.exe found file: . found file: .. found file: testfnf.cpp found file: testfnf.exe Error finding next file: 0
So, it looks like somewhere in FindClose Wine is resetting the last error. I started digging through there and the functions it calls but I was unable to find where it was getting reset. Can anyone shed some light on this? Is there any way to break on that value changing?
Thanks, -ajp