浏览代码

Report win32 last error string windows_file_open (#11224)

Kyle Sylvestre 1 年之前
父节点
当前提交
e5fa929245
共有 1 个文件被更改,包括 7 次插入1 次删除
  1. 7 1
      src/file/SDL_iostream.c

+ 7 - 1
src/file/SDL_iostream.c

@@ -133,7 +133,13 @@ static HANDLE SDLCALL windows_file_open(const char *filename, const char *mode)
 #endif
 #endif
 
 
     if (h == INVALID_HANDLE_VALUE) {
     if (h == INVALID_HANDLE_VALUE) {
-        SDL_SetError("Couldn't open %s", filename);
+        char *error;
+        if (SDL_asprintf(&error, "Couldn't open %s", filename) > 0) {
+            WIN_SetError(error);
+            SDL_free(error);
+        } else {
+            SDL_SetError("Couldn't open %s", filename);
+        }
     }
     }
     return h;
     return h;
 }
 }