Пример #1
0
void FileIndex::indexArchive(const std::string& archive)
{
	// Split directory from archive name
	auto slash = archive.find_last_of('/');
	auto directory = archive.substr(0, slash);
	auto archivebasename = archive.substr(slash+1);
	auto archivepath = directory + "/" + archivebasename;
	
	LoaderIMG img;
	
	if( ! img.load( archivepath ) )
	{
		throw std::runtime_error("Failed to load IMG archive: " + archivepath);
	}
	
	std::string lowerName;
	for( size_t i = 0; i < img.getAssetCount(); ++i )
	{
		auto& asset = img.getAssetInfoByIndex(i);
		
		if( asset.size == 0 ) continue;
		
		lowerName = asset.name;
		std::transform(lowerName.begin(), lowerName.end(), lowerName.begin(), ::tolower);
		
		files[ lowerName ] = {
			lowerName,
			asset.name,
			directory,
			archivebasename
		};
	}
}
Пример #2
0
void FileIndex::indexArchive(const std::string& archive)
{
	// Split directory from archive name
	path archive_path = path(archive);
	path directory = archive_path.parent_path();
	path archive_basename = archive_path.filename();
	path archive_full_path = directory/archive_basename;
	
	LoaderIMG img;	
	if(!img.load(archive_full_path.string())) {
		throw std::runtime_error("Failed to load IMG archive: " + archive_full_path.string());
	}
	
	std::string lowerName;
	for( size_t i = 0; i < img.getAssetCount(); ++i ) {
		auto& asset = img.getAssetInfoByIndex(i);
		
		if( asset.size == 0 ) continue;
		
		lowerName = asset.name;
		std::transform(lowerName.begin(), lowerName.end(), lowerName.begin(), ::tolower);
		
		files[lowerName] = {lowerName, asset.name, directory.string(), archive_basename.string()};
	}
}