diff --git a/Core/FileSystems/MetaFileSystem.cpp b/Core/FileSystems/MetaFileSystem.cpp index cfca21ce3..a1b96c7fc 100644 --- a/Core/FileSystems/MetaFileSystem.cpp +++ b/Core/FileSystems/MetaFileSystem.cpp @@ -171,6 +171,7 @@ IFileSystem *MetaFileSystem::GetHandleOwner(u32 handle) return 0; } +extern u32 errorCode; bool MetaFileSystem::MapFilePath(const std::string &_inpath, std::string &outpath, MountPoint **system) { std::string realpath; @@ -187,15 +188,18 @@ bool MetaFileSystem::MapFilePath(const std::string &_inpath, std::string &outpat int currentThread = __KernelGetCurThread(); currentDir_t::iterator it = currentDir.find(currentThread); - if (it == currentDir.end()) + if (it == currentDir.end()) { - //TODO: emulate PSP's error 8002032C: "no current working directory" if relative... may break things requiring fixes elsewhere - if (inpath.find(':') == std::string::npos /* means path is relative */) - WARN_LOG_REPORT(HLE, "Path is relative, but current directory not set for thread %i. Should give error, instead falling back to %s", currentThread, startingDirectory.c_str()); - } - else - { - currentDirectory = &(it->second); + //Attempt to emulate SCE_KERNEL_ERROR_NOCWD / 8002032C: may break things requiring fixes elsewhere + if (inpath.find(':') == std::string::npos /* means path is relative */) + { + errorCode = SCE_KERNEL_ERROR_NOCWD; + WARN_LOG_REPORT(HLE, "Path is relative, but current directory not set for thread %i. returning 8002032C(SCE_KERNEL_ERROR_NOCWD) instead.", currentThread, startingDirectory.c_str()); + } + else + { + currentDirectory = &(it->second); + } } if ( RealPath(*currentDirectory, inpath, realpath) ) diff --git a/Core/HLE/sceIo.cpp b/Core/HLE/sceIo.cpp index acba7bed9..76fc0b4f1 100644 --- a/Core/HLE/sceIo.cpp +++ b/Core/HLE/sceIo.cpp @@ -98,6 +98,7 @@ typedef s64 SceOff; typedef u64 SceIores; int asyncNotifyEvent = -1; +u32 errorCode = 0; #define SCE_STM_FDIR 0x1000 #define SCE_STM_FREG 0x2000 @@ -742,6 +743,9 @@ FileNode *__IoOpen(const char* filename, int flags, int mode) { access |= FILEACCESS_CREATE; PSPFileInfo info = pspFileSystem.GetFileInfo(filename); + + errorCode = 0; + u32 h = pspFileSystem.OpenFile(filename, (FileAccess) access); if (h == 0) { return NULL; @@ -766,10 +770,19 @@ u32 sceIoOpen(const char* filename, int flags, int mode) { return -1; FileNode *f = __IoOpen(filename, flags, mode); - if (f == NULL) { - ERROR_LOG(HLE, "ERROR_ERRNO_FILE_NOT_FOUND=sceIoOpen(%s, %08x, %08x) - file not found", filename, flags, mode); - // Timing is not accurate, aiming low for now. - return hleDelayResult(ERROR_ERRNO_FILE_NOT_FOUND, "file opened", 100); + if (f == NULL) + { + //Timing is not accurate, aiming low for now. + if(errorCode == SCE_KERNEL_ERROR_NOCWD) + { + ERROR_LOG(HLE, "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 + { + ERROR_LOG(HLE, "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); + } } SceUID id = f->GetUID();