瀏覽代碼

storage: Add error messages when ReadIO/WriteIO lengths mismatch

Ethan Lee 3 月之前
父節點
當前提交
3cd3c9317e
共有 1 個文件被更改,包括 4 次插入0 次删除
  1. 4 0
      src/storage/generic/SDL_genericstorage.c

+ 4 - 0
src/storage/generic/SDL_genericstorage.c

@@ -85,6 +85,8 @@ static bool GENERIC_ReadStorageFile(void *userdata, const char *path, void *dest
             // FIXME: Should SDL_ReadIO use u64 now...?
             if (SDL_ReadIO(stream, destination, (size_t)length) == length) {
                 result = true;
+            } else {
+                SDL_SetError("File length did not exactly match the destination length");
             }
             SDL_CloseIO(stream);
         }
@@ -110,6 +112,8 @@ static bool GENERIC_WriteStorageFile(void *userdata, const char *path, const voi
             // FIXME: Should SDL_WriteIO use u64 now...?
             if (SDL_WriteIO(stream, source, (size_t)length) == length) {
                 result = true;
+            } else {
+                SDL_SetError("Resulting file length did not exactly match the source length");
             }
             SDL_CloseIO(stream);
         }