mirror of
https://github.com/hrydgard/ppsspp.git
synced 2024-11-23 13:30:02 +00:00
Handle disk full more properly in sceIoWrite().
This commit is contained in:
parent
24ce3d11ed
commit
d4e8bd96af
@ -92,7 +92,7 @@ namespace
|
||||
size_t result = pspFileSystem.WriteFile(handle, data, dataSize);
|
||||
pspFileSystem.CloseFile(handle);
|
||||
|
||||
return result != 0;
|
||||
return result == dataSize;
|
||||
}
|
||||
|
||||
bool PSPMatch(std::string text, std::string regexp)
|
||||
|
@ -290,10 +290,19 @@ size_t DirectoryFileHandle::Read(u8* pointer, s64 size)
|
||||
size_t DirectoryFileHandle::Write(const u8* pointer, s64 size)
|
||||
{
|
||||
size_t bytesWritten = 0;
|
||||
bool diskFull = false;
|
||||
|
||||
#ifdef _WIN32
|
||||
::WriteFile(hFile, (LPVOID)pointer, (DWORD)size, (LPDWORD)&bytesWritten, 0);
|
||||
BOOL success = ::WriteFile(hFile, (LPVOID)pointer, (DWORD)size, (LPDWORD)&bytesWritten, 0);
|
||||
if (success == FALSE) {
|
||||
DWORD err = GetLastError();
|
||||
diskFull = err == ERROR_DISK_FULL || err == ERROR_NOT_ENOUGH_QUOTA;
|
||||
}
|
||||
#else
|
||||
bytesWritten = write(hFile, pointer, size);
|
||||
if (bytesWritten == (size_t)-1) {
|
||||
diskFull = errno == ENOSPC;
|
||||
}
|
||||
#endif
|
||||
if (needsTrunc_ != -1) {
|
||||
off_t off = (off_t)Seek(0, FILEMOVE_CURRENT);
|
||||
@ -301,6 +310,13 @@ size_t DirectoryFileHandle::Write(const u8* pointer, s64 size)
|
||||
needsTrunc_ = off;
|
||||
}
|
||||
}
|
||||
|
||||
if (diskFull) {
|
||||
// Sign extend on 64-bit.
|
||||
ERROR_LOG(FILESYS, "Disk full");
|
||||
return (size_t)(s64)(s32)SCE_KERNEL_ERROR_ERRNO_DEVICE_NO_FREE_SPACE;
|
||||
}
|
||||
|
||||
return bytesWritten;
|
||||
}
|
||||
|
||||
|
@ -96,7 +96,8 @@ void AsyncIOManager::Read(u32 handle, u8 *buf, size_t bytes) {
|
||||
}
|
||||
|
||||
void AsyncIOManager::Write(u32 handle, u8 *buf, size_t bytes) {
|
||||
size_t result = pspFileSystem.WriteFile(handle, buf, bytes);
|
||||
// We want to sign extend this on 32-bit.
|
||||
AsyncIOResult result = (ssize_t)pspFileSystem.WriteFile(handle, buf, bytes);
|
||||
EventResult(handle, result);
|
||||
}
|
||||
|
||||
|
@ -44,7 +44,7 @@ struct AsyncIOEvent {
|
||||
};
|
||||
|
||||
// TODO: Something better.
|
||||
typedef size_t AsyncIOResult;
|
||||
typedef s64 AsyncIOResult;
|
||||
|
||||
typedef ThreadEventQueue<NoBase, AsyncIOEvent, AsyncIOEventType, IO_EVENT_INVALID, IO_EVENT_SYNC, IO_EVENT_FINISH> IOThreadEventQueue;
|
||||
class AsyncIOManager : public IOThreadEventQueue {
|
||||
|
@ -57,7 +57,7 @@ public:
|
||||
Nothing = temp >> 16;
|
||||
|
||||
if (codec == PSP_CODEC_AT3) {
|
||||
// The first two bytes are actually not useful part of the extradata.
|
||||
// The first two bytes are actually not a useful part of the extradata.
|
||||
// We already read 16 bytes, so make sure there's enough left.
|
||||
if (file_.getCurrentChunkSize() >= 32) {
|
||||
file_.readData(at3_extradata, 16);
|
||||
|
Loading…
Reference in New Issue
Block a user