int MetaFileSystem::ChDir(const std::string &dir) { // Retain the old path and fail if the arg is 1023 bytes or longer. if (dir.size() >= 1023) return SCE_KERNEL_ERROR_NAMETOOLONG; int curThread = __KernelGetCurThread(); std::string of; MountPoint *mountPoint; if (MapFilePath(dir, of, &mountPoint)) { currentDir[curThread] = mountPoint->prefix + of; return 0; } else { for (size_t i = 0; i < fileSystems.size(); i++) { const std::string &prefix = fileSystems[i].prefix; if (strncasecmp(prefix.c_str(), dir.c_str(), prefix.size()) == 0) { // The PSP is completely happy with invalid current dirs as long as they have a valid device. WARN_LOG(HLE, "ChDir failed to map path \"%s\", saving as current directory anyway", dir.c_str()); currentDir[curThread] = dir; return 0; } } WARN_LOG(HLE, "ChDir failed to map device for \"%s\", failing", dir.c_str()); return SCE_KERNEL_ERROR_NODEV; } }
bool MetaFileSystem::GetHostPath(const std::string &inpath, std::string &outpath) { std::string of; IFileSystem *system; if (MapFilePath(inpath, of, &system)) { return system->GetHostPath(of, outpath); } else { return false; } }
u64 MetaFileSystem::FreeSpace(const std::string &path) { lock_guard guard(lock); std::string of; IFileSystem *system; if (MapFilePath(path, of, &system)) return system->FreeSpace(of); else return 0; }
bool MetaFileSystem::GetHostPath(const std::string &inpath, std::string &outpath) { std::lock_guard<std::recursive_mutex> guard(lock); std::string of; IFileSystem *system; if (MapFilePath(inpath, of, &system)) { return system->GetHostPath(of, outpath); } else { return false; } }
bool MetaFileSystem::RemoveFile(const std::string &filename) { std::string of; IFileSystem *system; if (MapFilePath(filename, of, &system)) { return system->RemoveFile(of); } else { return false; } }
bool MetaFileSystem::RmDir(const std::string &dirname) { std::string of; IFileSystem *system; if (MapFilePath(dirname, of, &system)) { return system->RmDir(of); } else { return false; } }
u32 MetaFileSystem::OpenFile(std::string filename, FileAccess access) { std::string of; IFileSystem *system; if (MapFilePath(filename, of, &system)) { return system->OpenFile(of, access); } else { return 0; } }
bool MetaFileSystem::MkDir(const std::string &dirname) { lock_guard guard(lock); std::string of; IFileSystem *system; if (MapFilePath(dirname, of, &system)) { return system->MkDir(of); } else { return false; } }
std::vector<PSPFileInfo> MetaFileSystem::GetDirListing(std::string path) { std::string of; IFileSystem *system; if (MapFilePath(path, of, &system)) { return system->GetDirListing(of); } else { std::vector<PSPFileInfo> empty; return empty; } }
PSPFileInfo MetaFileSystem::GetFileInfo(std::string filename) { std::string of; IFileSystem *system; if (MapFilePath(filename, of, &system)) { return system->GetFileInfo(of); } else { PSPFileInfo bogus; // TODO return bogus; } }
bool MetaFileSystem::RemoveFile(const std::string &filename) { std::lock_guard<std::recursive_mutex> guard(lock); std::string of; IFileSystem *system; if (MapFilePath(filename, of, &system)) { return system->RemoveFile(of); } else { return false; } }
u32 MetaFileSystem::OpenFile(std::string filename, FileAccess access, const char *devicename) { lock_guard guard(lock); lastOpenError = 0; std::string of; MountPoint *mount; if (MapFilePath(filename, of, &mount)) { return mount->system->OpenFile(of, access, mount->prefix.c_str()); } else { return 0; } }
std::vector<FileInfo> MetaFileSystem::GetDirListing(std::string path) { std::lock_guard<std::recursive_mutex> guard(lock); std::string of; IFileSystem *system; if (MapFilePath(path, of, &system)) { return system->GetDirListing(of); } else { std::vector<FileInfo> empty; return empty; } }
FileInfo MetaFileSystem::GetFileInfo(std::string filename) { std::lock_guard<std::recursive_mutex> guard(lock); std::string of; IFileSystem *system; if (MapFilePath(filename, of, &system)) { return system->GetFileInfo(of); } else { FileInfo bogus; // TODO return bogus; } }