mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
Loaders: Prevent errors on 0 byte reads.
Was happening when opening an http:// GE frame dump.
This commit is contained in:
parent
8205f9b6f2
commit
a20c972d55
2 changed files with 10 additions and 0 deletions
|
@ -98,6 +98,10 @@ size_t DiskCachingFileLoader::ReadAt(s64 absolutePos, size_t bytes, void *data,
|
|||
// While in case the cache size is too small for the entire read.
|
||||
while (readSize < bytes) {
|
||||
readSize += cache_->SaveIntoCache(backend_, absolutePos + readSize, bytes - readSize, (u8 *)data + readSize, flags);
|
||||
// We're done, nothing more to read.
|
||||
if (readSize == bytes) {
|
||||
break;
|
||||
}
|
||||
// If there are already-cached blocks afterward, we have to read them.
|
||||
size_t bytesFromCache = cache_->ReadFromCache(absolutePos + readSize, bytes - readSize, (u8 *)data + readSize);
|
||||
readSize += bytesFromCache;
|
||||
|
@ -441,6 +445,9 @@ bool DiskCachingFileLoaderCache::ReadBlockData(u8 *dest, BlockInfo &info, size_t
|
|||
if (!f_) {
|
||||
return false;
|
||||
}
|
||||
if (size == 0) {
|
||||
return true;
|
||||
}
|
||||
s64 blockOffset = GetBlockOffset(info.block);
|
||||
|
||||
// Before we read, make sure the buffers are flushed.
|
||||
|
|
|
@ -119,6 +119,9 @@ std::string LocalFileLoader::Path() const {
|
|||
}
|
||||
|
||||
size_t LocalFileLoader::ReadAt(s64 absolutePos, size_t bytes, size_t count, void *data, Flags flags) {
|
||||
if (bytes == 0)
|
||||
return 0;
|
||||
|
||||
#if PPSSPP_PLATFORM(SWITCH)
|
||||
// Toolchain has no fancy IO API. We must lock.
|
||||
std::lock_guard<std::mutex> guard(readLock_);
|
||||
|
|
Loading…
Add table
Reference in a new issue