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:
[EMAIL PROTECTED] 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




Reply via email to