Io: Cleanup sceIoOpen errors and logging.

This commit is contained in:
Unknown W. Brackets 2020-05-21 15:08:10 -07:00
parent 1dec772145
commit 3777d32ac8
2 changed files with 20 additions and 28 deletions

View file

@ -178,7 +178,7 @@ IFileSystem *MetaFileSystem::GetHandleOwner(u32 handle)
int MetaFileSystem::MapFilePath(const std::string &_inpath, std::string &outpath, MountPoint **system)
{
int error = -1;
int error = SCE_KERNEL_ERROR_ERRNO_FILE_NOT_FOUND;
std::lock_guard<std::recursive_mutex> guard(lock);
std::string realpath;
@ -246,6 +246,8 @@ int MetaFileSystem::MapFilePath(const std::string &_inpath, std::string &outpath
return error == SCE_KERNEL_ERROR_NOCWD ? error : 0;
}
}
error = SCE_KERNEL_ERROR_NODEV;
}
DEBUG_LOG(FILESYS, "MapFilePath: failed mapping \"%s\", returning false", inpath.c_str());
@ -353,7 +355,7 @@ int MetaFileSystem::OpenFile(std::string filename, FileAccess access, const char
if (error == 0)
return mount->system->OpenFile(of, access, mount->prefix.c_str());
else
return error == -1 ? SCE_KERNEL_ERROR_ERRNO_FILE_NOT_FOUND : error;
return error;
}
PSPFileInfo MetaFileSystem::GetFileInfo(std::string filename)

View file

@ -1463,41 +1463,33 @@ static FileNode *__IoOpen(int &error, const char* filename, int flags, int mode)
}
static u32 sceIoOpen(const char *filename, int flags, int mode) {
if (!__KernelIsDispatchEnabled())
return -1;
if (!__KernelIsDispatchEnabled()) {
return hleLogError(SCEIO, SCE_KERNEL_ERROR_CAN_NOT_WAIT, "dispatch disabled");
}
int error;
FileNode *f = __IoOpen(error, filename, flags, mode);
if (f == NULL)
{
// Timing is not accurate, aiming low for now.
if (error == (int)SCE_KERNEL_ERROR_NOCWD)
{
ERROR_LOG(SCEIO, "SCE_KERNEL_ERROR_NOCWD=sceIoOpen(%s, %08x, %08x) - no current working directory", filename, flags, mode);
return hleDelayResult(SCE_KERNEL_ERROR_NOCWD, "no cwd", 10000);
}
else if (error != 0)
{
ERROR_LOG(SCEIO, "%08x=sceIoOpen(%s, %08x, %08x)", error, filename, flags, mode);
return hleDelayResult(error, "file opened", 10000);
}
else
{
ERROR_LOG(SCEIO, "ERROR_ERRNO_FILE_NOT_FOUND=sceIoOpen(%s, %08x, %08x) - file not found", filename, flags, mode);
return hleDelayResult(SCE_KERNEL_ERROR_ERRNO_FILE_NOT_FOUND, "file opened", 10000);
if (!f) {
assert(error != 0);
if (error == (int)SCE_KERNEL_ERROR_NOCWD) {
// TODO: Timing is not accurate.
return hleLogError(SCEIO, hleDelayResult(error, "file opened", 10000), "no current working directory");
} else if (error == (int)SCE_KERNEL_ERROR_ERRNO_FILE_NOT_FOUND) {
// TODO: Depends on filesys.
return hleLogWarning(SCEIO, hleDelayResult(error, "file opened", 10000), "file not found");
} else {
return hleLogError(SCEIO, hleDelayResult(error, "file opened", 10000));
}
}
int id = __IoAllocFd(f);
if (id < 0) {
ERROR_LOG(SCEIO, "%08x=sceIoOpen(%s, %08x, %08x): out of fds", id, filename, flags, mode);
kernelObjects.Destroy<FileNode>(f->GetUID());
return id;
return hleLogError(SCEIO, id, "out of fds");
} else {
DEBUG_LOG(SCEIO, "%i=sceIoOpen(%s, %08x, %08x)", id, filename, flags, mode);
asyncParams[id].priority = asyncDefaultPriority;
// Timing is not accurate, aiming low for now.
return hleDelayResult(id, "file opened", 100);
return hleLogSuccessI(SCEIO, hleDelayResult(id, "file opened", 100));
}
}
@ -2044,9 +2036,7 @@ static u32 sceIoOpenAsync(const char *filename, int flags, int mode)
// We have to return an fd here, which may have been destroyed when we reach Wait if it failed.
if (f == nullptr) {
if (error == 0)
error = SCE_KERNEL_ERROR_ERRNO_FILE_NOT_FOUND;
assert(error != 0);
f = new FileNode();
f->handle = kernelObjects.Create(f);
f->fullpath = filename;