diff --git a/Core/FileSystems/MetaFileSystem.cpp b/Core/FileSystems/MetaFileSystem.cpp index cfca21ce3a..f14261e0b9 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,11 +188,12 @@ bool MetaFileSystem::MapFilePath(const std::string &_inpath, std::string &outpat int currentThread = __KernelGetCurThread(); currentDir_t::iterator it = currentDir.find(currentThread); - if (it == currentDir.end()) + //Attempt to emulate SCE_KERNEL_ERROR_NOCWD / 8002032C: may break things requiring fixes elsewhere + if (inpath.find(':') == std::string::npos /* means path is relative */) { - //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()); + 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()); + return false; } else { diff --git a/Core/HLE/sceIo.cpp b/Core/HLE/sceIo.cpp index acba7bed92..d353de56f6 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 @@ -766,10 +767,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); + if (f == NULL) + { // Timing is not accurate, aiming low for now. - return hleDelayResult(ERROR_ERRNO_FILE_NOT_FOUND, "file opened", 100); + 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", 100); + } + 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", 100); + } } SceUID id = f->GetUID();