Skip to content

Commit c72f1fd

Browse files
fix windows EOF check
1 parent 9ad04ff commit c72f1fd

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/io/SDL_iostream.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,6 @@ static size_t SDLCALL windows_file_read(void *userdata, void *ptr, size_t size,
219219
DWORD error = GetLastError();
220220
switch (error) {
221221
case ERROR_BROKEN_PIPE:
222-
case ERROR_HANDLE_EOF:
223222
*status = SDL_IO_STATUS_EOF;
224223
break;
225224
case ERROR_NO_DATA:
@@ -231,6 +230,8 @@ static size_t SDLCALL windows_file_read(void *userdata, void *ptr, size_t size,
231230
break;
232231
}
233232
return 0; // !!! FIXME: this should return the bytes read from any readahead we finished out before this (the `iodata->left > 0` code above). In that case, fail on the next read.
233+
} else if (bytes == 0) {
234+
*status = SDL_IO_STATUS_EOF;
234235
}
235236
read_ahead = SDL_min(total_need, bytes);
236237
SDL_memcpy(ptr, iodata->data, read_ahead);
@@ -242,7 +243,6 @@ static size_t SDLCALL windows_file_read(void *userdata, void *ptr, size_t size,
242243
DWORD error = GetLastError();
243244
switch (error) {
244245
case ERROR_BROKEN_PIPE:
245-
case ERROR_HANDLE_EOF:
246246
*status = SDL_IO_STATUS_EOF;
247247
break;
248248
case ERROR_NO_DATA:
@@ -254,6 +254,8 @@ static size_t SDLCALL windows_file_read(void *userdata, void *ptr, size_t size,
254254
break;
255255
}
256256
return 0; // !!! FIXME: this should return the bytes read from any readahead we finished out before this (the `iodata->left > 0` code above). In that case, fail on the next read.
257+
} else if (bytes == 0) {
258+
*status = SDL_IO_STATUS_EOF;
257259
}
258260
total_read += bytes;
259261
}

0 commit comments

Comments
 (0)