bool CachingFileLoader::IsDirectory() { if (isDirectory_ == -1) { lock_guard guard(backendMutex_); isDirectory_ = backend_->IsDirectory() ? 1 : 0; } return isDirectory_ == 1; }
void __UmdReplace(std::string filepath) { // TODO: This should really go through Loaders, no? What if it's an invalid file? // Only get system from disc0 seems have been enough. IFileSystem* currentUMD = pspFileSystem.GetSystem("disc0:"); IFileSystem* currentISOBlock = pspFileSystem.GetSystem("umd0:"); if (!currentUMD) return; FileLoader *loadedFile = ConstructFileLoader(filepath); IFileSystem* umd2; if (!loadedFile->Exists()) { delete loadedFile; return; } UpdateLoadedFile(loadedFile); if (loadedFile->IsDirectory()) { umd2 = new VirtualDiscFileSystem(&pspFileSystem, filepath); } else { auto bd = constructBlockDevice(loadedFile); if (!bd) return; umd2 = new ISOFileSystem(&pspFileSystem, bd); pspFileSystem.Remount(currentUMD, umd2); if (currentUMD != currentISOBlock) { // We mounted an ISO block system separately. IFileSystem *iso = new ISOBlockSystem(static_cast<ISOFileSystem *>(umd2)); pspFileSystem.Remount(currentISOBlock, iso); delete currentISOBlock; } } delete currentUMD; // TODO Is this always correct if UMD was not activated? u32 notifyArg = PSP_UMD_PRESENT | PSP_UMD_READABLE | PSP_UMD_CHANGED; if (driveCBId != -1) __KernelNotifyCallback(driveCBId, notifyArg); }