file->FileAttributes, NULL);
}
+#ifdef WIN32
if (file->file_handle == INVALID_HANDLE_VALUE)
{
/* Get the error message, if any. */
if (errorMessageID != 0)
{
-#ifdef WIN32
LPSTR messageBuffer = NULL;
size_t size = FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
WLog_ERR(TAG, "Error in drive_file_init: %s %s", messageBuffer, file->fullpath);
/* Free the buffer. */
LocalFree(messageBuffer);
-#endif
+ /* restore original error code */
+ SetLastError(errorMessageID);
}
}
+#endif
return file->file_handle != INVALID_HANDLE_VALUE;
}
if (!drive_file_init(file))
{
+ DWORD lastError = GetLastError();
drive_file_free(file);
+ SetLastError(lastError);
return NULL;
}