예제 #1
0
파일: Loaders.cpp 프로젝트: Bigpet/ppsspp
bool CachingFileLoader::Exists() {
	if (exists_ == -1) {
		lock_guard guard(backendMutex_);
		exists_ = backend_->Exists() ? 1 : 0;
	}
	return exists_ == 1;
}
예제 #2
0
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);
}
예제 #3
0
void Config::AddRecent(const std::string &file) {
	// Don't bother with this if the user disabled recents (it's -1).
	if (iMaxRecent <= 0)
		return;

	for (auto str = recentIsos.begin(); str != recentIsos.end(); ++str) {
#ifdef _WIN32
		if (!strcmpIgnore((*str).c_str(), file.c_str(), "\\", "/")) {
#else
		if (!strcmp((*str).c_str(), file.c_str())) {
#endif
			recentIsos.erase(str);
			recentIsos.insert(recentIsos.begin(), file);
			if ((int)recentIsos.size() > iMaxRecent)
				recentIsos.resize(iMaxRecent);
			return;
		}
	}
	recentIsos.insert(recentIsos.begin(), file);
	if ((int)recentIsos.size() > iMaxRecent)
		recentIsos.resize(iMaxRecent);
}

void Config::CleanRecent() {
	std::vector<std::string> cleanedRecent;
	for (size_t i = 0; i < recentIsos.size(); i++) {
		FileLoader *loader = ConstructFileLoader(recentIsos[i]);
		if (loader->Exists()) {
			// Make sure we don't have any redundant items.
			auto duplicate = std::find(cleanedRecent.begin(), cleanedRecent.end(), recentIsos[i]);
			if (duplicate == cleanedRecent.end()) {
				cleanedRecent.push_back(recentIsos[i]);
			}
		}
		delete loader;
	}
	recentIsos = cleanedRecent;
}