mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-09-28 14:08:28 +00:00
fix windows EOF check
This commit is contained in:

committed by
Sam Lantinga

parent
9ad04ff69e
commit
3876ce3495
@@ -219,7 +219,6 @@ static size_t SDLCALL windows_file_read(void *userdata, void *ptr, size_t size,
|
|||||||
DWORD error = GetLastError();
|
DWORD error = GetLastError();
|
||||||
switch (error) {
|
switch (error) {
|
||||||
case ERROR_BROKEN_PIPE:
|
case ERROR_BROKEN_PIPE:
|
||||||
case ERROR_HANDLE_EOF:
|
|
||||||
*status = SDL_IO_STATUS_EOF;
|
*status = SDL_IO_STATUS_EOF;
|
||||||
break;
|
break;
|
||||||
case ERROR_NO_DATA:
|
case ERROR_NO_DATA:
|
||||||
@@ -231,6 +230,8 @@ static size_t SDLCALL windows_file_read(void *userdata, void *ptr, size_t size,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
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.
|
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.
|
||||||
|
} else if (bytes == 0) {
|
||||||
|
*status = SDL_IO_STATUS_EOF;
|
||||||
}
|
}
|
||||||
read_ahead = SDL_min(total_need, bytes);
|
read_ahead = SDL_min(total_need, bytes);
|
||||||
SDL_memcpy(ptr, iodata->data, read_ahead);
|
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,
|
|||||||
DWORD error = GetLastError();
|
DWORD error = GetLastError();
|
||||||
switch (error) {
|
switch (error) {
|
||||||
case ERROR_BROKEN_PIPE:
|
case ERROR_BROKEN_PIPE:
|
||||||
case ERROR_HANDLE_EOF:
|
|
||||||
*status = SDL_IO_STATUS_EOF;
|
*status = SDL_IO_STATUS_EOF;
|
||||||
break;
|
break;
|
||||||
case ERROR_NO_DATA:
|
case ERROR_NO_DATA:
|
||||||
@@ -254,6 +254,8 @@ static size_t SDLCALL windows_file_read(void *userdata, void *ptr, size_t size,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
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.
|
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.
|
||||||
|
} else if (bytes == 0) {
|
||||||
|
*status = SDL_IO_STATUS_EOF;
|
||||||
}
|
}
|
||||||
total_read += bytes;
|
total_read += bytes;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user