Skip to content

Commit

Permalink
Merge pull request #11009 from unknownbrackets/file-error
Browse files Browse the repository at this point in the history
Io: Cleanup file not found error codes
  • Loading branch information
hrydgard authored May 6, 2018
2 parents 746a325 + f4e8e68 commit 8f5a23b
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 14 deletions.
10 changes: 8 additions & 2 deletions Core/FileSystems/DirectoryFileSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,10 @@ bool DirectoryFileHandle::Open(std::string &basePath, std::string &fileName, Fil
#if HOST_IS_CASE_SENSITIVE
if (access & (FILEACCESS_APPEND|FILEACCESS_CREATE|FILEACCESS_WRITE)) {
DEBUG_LOG(FILESYS, "Checking case for path %s", fileName.c_str());
if (!FixPathCase(basePath, fileName, FPC_PATH_MUST_EXIST) )
if (!FixPathCase(basePath, fileName, FPC_PATH_MUST_EXIST)) {
error = SCE_KERNEL_ERROR_ERRNO_FILE_NOT_FOUND;
return false; // or go on and attempt (for a better error code than just 0?)
}
}
// else we try fopen first (in case we're lucky) before simulating case insensitivity
#endif
Expand Down Expand Up @@ -250,6 +252,8 @@ bool DirectoryFileHandle::Open(std::string &basePath, std::string &fileName, Fil
I18NCategory *err = GetI18NCategory("Error");
host->NotifyUserMessage(err->T("Disk full while writing data"));
error = SCE_KERNEL_ERROR_ERRNO_NO_PERM;
} else {
error = SCE_KERNEL_ERROR_ERRNO_FILE_NOT_FOUND;
}
}
#else
Expand Down Expand Up @@ -310,6 +314,8 @@ bool DirectoryFileHandle::Open(std::string &basePath, std::string &fileName, Fil
I18NCategory *err = GetI18NCategory("Error");
host->NotifyUserMessage(err->T("Disk full while writing data"));
error = SCE_KERNEL_ERROR_ERRNO_NO_PERM;
} else {
error = SCE_KERNEL_ERROR_ERRNO_FILE_NOT_FOUND;
}
#endif

Expand Down Expand Up @@ -597,7 +603,7 @@ u32 DirectoryFileSystem::OpenFile(std::string filename, FileAccess access, const
u32 err = 0;
bool success = entry.hFile.Open(basePath, filename, access, err);
if (err == 0 && !success) {
err = -1;
err = SCE_KERNEL_ERROR_ERRNO_FILE_NOT_FOUND;
}

err = ReplayApplyDisk(ReplayAction::FILE_OPEN, err, CoreTiming::GetGlobalTimeUs());
Expand Down
18 changes: 8 additions & 10 deletions Core/HLE/sceIo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ extern "C" {
// For headless screenshots.
#include "Core/HLE/sceDisplay.h"

static const int ERROR_ERRNO_FILE_NOT_FOUND = 0x80010002;
static const int ERROR_ERRNO_IO_ERROR = 0x80010005;
static const int ERROR_MEMSTICK_DEVCTL_BAD_PARAMS = 0x80220081;
static const int ERROR_MEMSTICK_DEVCTL_TOO_MANY_CALLBACKS = 0x80220082;
Expand Down Expand Up @@ -805,7 +804,7 @@ static u32 sceIoGetstat(const char *filename, u32 addr) {
}
} else {
DEBUG_LOG(SCEIO, "sceIoGetstat(%s, %08x) : FILE NOT FOUND", filename, addr);
return hleDelayResult(ERROR_ERRNO_FILE_NOT_FOUND, "io getstat", usec);
return hleDelayResult(SCE_KERNEL_ERROR_ERRNO_FILE_NOT_FOUND, "io getstat", usec);
}
}

Expand Down Expand Up @@ -1383,7 +1382,7 @@ static u32 sceIoOpen(const char *filename, int flags, int mode) {
else
{
ERROR_LOG(SCEIO, "ERROR_ERRNO_FILE_NOT_FOUND=sceIoOpen(%s, %08x, %08x) - file not found", filename, flags, mode);
return hleDelayResult(ERROR_ERRNO_FILE_NOT_FOUND, "file opened", 10000);
return hleDelayResult(SCE_KERNEL_ERROR_ERRNO_FILE_NOT_FOUND, "file opened", 10000);
}
}

Expand Down Expand Up @@ -1412,7 +1411,7 @@ static u32 sceIoRemove(const char *filename) {

// TODO: This timing isn't necessarily accurate, low end for now.
if(!pspFileSystem.GetFileInfo(filename).exists)
return hleDelayResult(ERROR_ERRNO_FILE_NOT_FOUND, "file removed", 100);
return hleDelayResult(SCE_KERNEL_ERROR_ERRNO_FILE_NOT_FOUND, "file removed", 100);

pspFileSystem.RemoveFile(filename);
return hleDelayResult(0, "file removed", 100);
Expand All @@ -1433,7 +1432,7 @@ static u32 sceIoRmdir(const char *dirname) {
if (pspFileSystem.RmDir(dirname))
return hleDelayResult(0, "rmdir", 1000);
else
return hleDelayResult(ERROR_ERRNO_FILE_NOT_FOUND, "rmdir", 1000);
return hleDelayResult(SCE_KERNEL_ERROR_ERRNO_FILE_NOT_FOUND, "rmdir", 1000);
}

static u32 sceIoSync(const char *devicename, int flag) {
Expand Down Expand Up @@ -1855,7 +1854,7 @@ static u32 sceIoRename(const char *from, const char *to) {

// TODO: Timing isn't terribly accurate.
if (!pspFileSystem.GetFileInfo(from).exists)
return hleDelayResult(ERROR_ERRNO_FILE_NOT_FOUND, "file renamed", 1000);
return hleDelayResult(SCE_KERNEL_ERROR_ERRNO_FILE_NOT_FOUND, "file renamed", 1000);

int result = pspFileSystem.RenameFile(from, to);
if (result < 0)
Expand Down Expand Up @@ -1933,7 +1932,7 @@ static u32 sceIoOpenAsync(const char *filename, int flags, int mode)
f = new FileNode();
f->handle = kernelObjects.Create(f);
f->fullpath = filename;
f->asyncResult = error == 0 ? ERROR_ERRNO_FILE_NOT_FOUND : error;
f->asyncResult = error == 0 ? SCE_KERNEL_ERROR_ERRNO_FILE_NOT_FOUND : error;
f->closePending = true;

fd = __IoAllocFd(f);
Expand Down Expand Up @@ -2142,9 +2141,8 @@ class DirListing : public KernelObject {
static u32 sceIoDopen(const char *path) {
DEBUG_LOG(SCEIO, "sceIoDopen(\"%s\")", path);

if(!pspFileSystem.GetFileInfo(path).exists)
{
return ERROR_ERRNO_FILE_NOT_FOUND;
if (!pspFileSystem.GetFileInfo(path).exists) {
return SCE_KERNEL_ERROR_ERRNO_FILE_NOT_FOUND;
}

DirListing *dir = new DirListing();
Expand Down
1 change: 1 addition & 0 deletions Core/HLE/sceKernel.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ enum {
SCE_KERNEL_ERROR_BAD_FILE = 0x80000209,
SCE_KERNEL_ERROR_ACCESS_ERROR = 0x8000020D,

SCE_KERNEL_ERROR_ERRNO_FILE_NOT_FOUND = 0x80010002,
SCE_KERNEL_ERROR_ERRNO_ARG_LIST_TOO_LONG = 0x80010007,
SCE_KERNEL_ERROR_ERRNO_INVALID_FILE_DESCRIPTOR = 0x80010009,
SCE_KERNEL_ERROR_ERRNO_RESOURCE_UNAVAILABLE = 0x8001000B,
Expand Down
3 changes: 1 addition & 2 deletions Core/HLE/sceKernelModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1811,8 +1811,7 @@ u32 sceKernelLoadModule(const char *name, u32 flags, u32 optionAddr) {
s64 size = (s64)info.size;

if (!info.exists) {
const int ERROR_ERRNO_FILE_NOT_FOUND = 0x80010002;
const u32 error = hleLogError(LOADER, ERROR_ERRNO_FILE_NOT_FOUND, "file does not exist");
const u32 error = hleLogError(LOADER, SCE_KERNEL_ERROR_ERRNO_FILE_NOT_FOUND, "file does not exist");
return hleDelayResult(error, "module loaded", 500);
}

Expand Down

0 comments on commit 8f5a23b

Please sign in to comment.