```c if (hIn == INVALID_HANDLE_VALUE) { DWORD is_dir_error; /* Store GetLastError right after CreateFileW so that it isn't overwritten */ is_dir_error = GetLastError(); return_code = ERROR_INVALID_FUNCTION; WCMD_print_error (); WCMD_output_stderr(WCMD_LoadMessage(WCMD_READFAIL), srcpath); FindClose(hff); /* Invalid directory path; Return immediately */ if(is_dir_error == ERROR_PATH_NOT_FOUND) { return errorlevel = ERROR_INVALID_FUNCTION; } continue; } ``` A small note on the above code snippet. Calling `GetLastError` in the if like `if (GetLastError() == ERROR_PATH_NOT_FOUND)` succeeded when I tried the test scripts manually, but failed while running the test, because GetLastError at that point was returning `ERROR_INVALID_HANDLE`. Thus, I store the results of a GetLastError made right after the CreateFileW call in a variable. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/11094#note_143662