Пример #1
0
CArchiveScanner::~CArchiveScanner()
{
	if (!isDirty)
		return;

	WriteCacheData(GetFilepath());
}
Пример #2
0
CArchiveScanner::CArchiveScanner()
: isDirty(false)
{
	std::ostringstream file;

	// the "cache" dir is created in DataDirLocater
	file << FileSystem::GetCacheDir();
	file << FileSystem::GetNativePathSeparator();
	file << "ArchiveCache.lua";

	cachefile = file.str();
	ReadCacheData(dataDirLocater.GetWriteDirPath() + GetFilename());

	const std::vector<std::string>& datadirs = dataDirLocater.GetDataDirPaths();
	std::vector<std::string> scanDirs;
	for (std::vector<std::string>::const_reverse_iterator d = datadirs.rbegin(); d != datadirs.rend(); ++d) {
		scanDirs.push_back(*d + "maps");
		scanDirs.push_back(*d + "base");
		scanDirs.push_back(*d + "games");
		scanDirs.push_back(*d + "packages");
	}
	// ArchiveCache has been parsed at this point --> archiveInfos is populated
	ScanDirs(scanDirs, true);
	WriteCacheData(dataDirLocater.GetWriteDirPath() + GetFilename());
}
Пример #3
0
void CArchiveScanner::Reload()
{
	// {Read,Write,Scan}* all grab this too but we need the entire reloading-sequence to appear atomic
	std::lock_guard<spring::recursive_mutex> lck(scannerMutex);

	// dtor
	if (isDirty)
		WriteCacheData(GetFilepath());

	archiveInfos.clear();
	brokenArchives.clear();
	cachefile.clear();

	// ctor
	ReadCacheData(cachefile = FileSystem::EnsurePathSepAtEnd(FileSystem::GetCacheDir()) + IntToString(INTERNAL_VER, "ArchiveCache%i.lua"));
	ScanAllDirs();
}
Пример #4
0
CArchiveScanner::CArchiveScanner()
: isDirty(false)
{
	std::ostringstream file;
	// the "cache" dir is created in DataDirLocater
	file << "cache" << (char)FileSystemHandler::GetNativePathSeparator() << "ArchiveCache.lua";
	cachefile = file.str();
	FileSystemHandler& fsh = FileSystemHandler::GetInstance();
	ReadCacheData(fsh.GetWriteDir() + GetFilename());

	const std::vector<std::string>& datadirs = fsh.GetDataDirectories();
	std::vector<std::string> scanDirs;
	for (std::vector<std::string>::const_reverse_iterator d = datadirs.rbegin(); d != datadirs.rend(); ++d) {
		scanDirs.push_back(*d + "maps");
		scanDirs.push_back(*d + "base");
		scanDirs.push_back(*d + "mods");
		scanDirs.push_back(*d + "packages");
	}
	ScanDirs(scanDirs, true);
	WriteCacheData(fsh.GetWriteDir() + GetFilename());
}
Пример #5
0
void CArchiveScanner::ScanAllDirs()
{
	std::lock_guard<spring::recursive_mutex> lck(scannerMutex);

	const std::vector<std::string>& dataDirs = dataDirLocater.GetDataDirPaths();
	std::vector<std::string> scanDirs;
	scanDirs.reserve(dataDirs.size());

	for (auto d = dataDirs.rbegin(); d != dataDirs.rend(); ++d) {
		scanDirs.push_back(*d + "maps");
		scanDirs.push_back(*d + "base");
		scanDirs.push_back(*d + "games");
		scanDirs.push_back(*d + "packages");
	}

	// ArchiveCache has been parsed at this point --> archiveInfos is populated
#if !defined(DEDICATED) && !defined(UNITSYNC)
	ScopedOnceTimer foo("CArchiveScanner::ScanAllDirs");
#endif

	ScanDirs(scanDirs);
	WriteCacheData(GetFilepath());
}
Пример #6
0
CArchiveScanner::CArchiveScanner()
: isDirty(false)
{
	// the "cache" dir is created in DataDirLocater
	const std:: string cacheFolder = dataDirLocater.GetWriteDirPath() + FileSystem::EnsurePathSepAtEnd(FileSystem::GetCacheBaseDir());
	cachefile = cacheFolder + IntToString(INTERNAL_VER, "ArchiveCache%i.lua");
	ReadCacheData(GetFilepath());
	if (archiveInfos.empty()) {
		// when versioned ArchiveCache%i.lua is missing or empty, try old unversioned filename
		ReadCacheData(cacheFolder + "ArchiveCache.lua");
	}

	const std::vector<std::string>& datadirs = dataDirLocater.GetDataDirPaths();
	std::vector<std::string> scanDirs;
	for (auto d = datadirs.rbegin(); d != datadirs.rend(); ++d) {
		scanDirs.push_back(*d + "maps");
		scanDirs.push_back(*d + "base");
		scanDirs.push_back(*d + "games");
		scanDirs.push_back(*d + "packages");
	}
	// ArchiveCache has been parsed at this point --> archiveInfos is populated
	ScanDirs(scanDirs, true);
	WriteCacheData(GetFilepath());
}
Пример #7
0
CArchiveScanner::~CArchiveScanner()
{
	if (isDirty) {
		WriteCacheData(filesystem.LocateFile(GetFilename(), FileSystem::WRITE));
	}
}
Пример #8
0
CArchiveScanner::~CArchiveScanner()
{
	if (isDirty) {
		WriteCacheData(GetFilepath());
	}
}
Пример #9
0
CArchiveScanner::~CArchiveScanner()
{
	if (isDirty) {
		WriteCacheData(dataDirsAccess.LocateFile(GetFilename(), FileQueryFlags::WRITE));
	}
}