diff --git a/src/xrCore/FS.cpp b/src/xrCore/FS.cpp index 3be6745221e..b83a87ea2a4 100644 --- a/src/xrCore/FS.cpp +++ b/src/xrCore/FS.cpp @@ -131,13 +131,25 @@ bool file_handle_internal(pcstr file_name, size_t& size, int& file_handle) void* FileDownload(pcstr file_name, const int& file_handle, size_t& file_size) { + VERIFY(file_size != 0); void* buffer = xr_malloc(file_size); - int r_bytes = _read(file_handle, buffer, file_size); - R_ASSERT3( - // !file_size || - // (r_bytes && (file_size >= (u32)r_bytes)), - file_size == (u32)r_bytes, "can't read from file : ", file_name); +#ifdef XR_PLATFORM_LINUX + size_t total_r_bytes = 0; + do + { + const ssize_t r_bytes = + _read(file_handle, reinterpret_cast(buffer) + total_r_bytes, file_size - total_r_bytes); + R_ASSERT3(r_bytes > 0, "Can't read from file : ", file_name); + + total_r_bytes += r_bytes; + } while (total_r_bytes < file_size); +#elif defined(XR_PLATFORM_WINDOWS) || defined(XR_PLATFORM_BSD) || defined(XR_PLATFORM_APPLE) + int total_r_bytes = _read(file_handle, buffer, file_size); +#else +# error Select or add implementation for your platform +#endif + R_ASSERT3(total_r_bytes == file_size, "Can't read from file : ", file_name); // file_size = r_bytes;