mirror of
https://github.com/vcmi/vcmi.git
synced 2025-08-13 19:54:17 +02:00
fix Boost deprecation warnings
warnings introduced in v1.81 # Conflicts: # mapeditor/resourceExtractor/ResourceConverter.cpp
This commit is contained in:
committed by
Ivan Savenko
parent
efbed6000b
commit
2f14914120
@@ -1702,7 +1702,7 @@ int CPlayerInterface::getLastIndex( std::string namePrefix)
|
|||||||
else
|
else
|
||||||
for (directory_iterator dir(gamesDir); dir != enddir; ++dir)
|
for (directory_iterator dir(gamesDir); dir != enddir; ++dir)
|
||||||
{
|
{
|
||||||
if (is_regular(dir->status()))
|
if (is_regular_file(dir->status()))
|
||||||
{
|
{
|
||||||
std::string name = dir->path().filename().string();
|
std::string name = dir->path().filename().string();
|
||||||
if (starts_with(name, namePrefix) && ends_with(name, ".vcgm1"))
|
if (starts_with(name, namePrefix) && ends_with(name, ".vcgm1"))
|
||||||
|
@@ -112,18 +112,31 @@ std::unordered_map<ResourceID, bfs::path> CFilesystemLoader::listFiles(const std
|
|||||||
std::vector<bfs::path> path; //vector holding relative path to our file
|
std::vector<bfs::path> path; //vector holding relative path to our file
|
||||||
|
|
||||||
bfs::recursive_directory_iterator enddir;
|
bfs::recursive_directory_iterator enddir;
|
||||||
|
#if BOOST_VERSION >= 107200 // 1.72
|
||||||
|
bfs::recursive_directory_iterator it(baseDirectory, bfs::directory_options::follow_directory_symlink);
|
||||||
|
#else
|
||||||
bfs::recursive_directory_iterator it(baseDirectory, bfs::symlink_option::recurse);
|
bfs::recursive_directory_iterator it(baseDirectory, bfs::symlink_option::recurse);
|
||||||
|
#endif
|
||||||
|
|
||||||
for(; it != enddir; ++it)
|
for(; it != enddir; ++it)
|
||||||
{
|
{
|
||||||
EResType::Type type;
|
EResType::Type type;
|
||||||
|
#if BOOST_VERSION >= 107200
|
||||||
|
const auto currentDepth = it.depth();
|
||||||
|
#else
|
||||||
|
const auto currentDepth = it.level();
|
||||||
|
#endif
|
||||||
|
|
||||||
if (bfs::is_directory(it->status()))
|
if (bfs::is_directory(it->status()))
|
||||||
{
|
{
|
||||||
path.resize(it.level() + 1);
|
path.resize(currentDepth + 1);
|
||||||
path.back() = it->path().filename();
|
path.back() = it->path().filename();
|
||||||
// don't iterate into directory if depth limit reached
|
// don't iterate into directory if depth limit reached
|
||||||
it.no_push(depth <= it.level());
|
#if BOOST_VERSION >= 107200
|
||||||
|
it.disable_recursion_pending(depth <= currentDepth);
|
||||||
|
#else
|
||||||
|
it.no_push(depth <= currentDepth);
|
||||||
|
#endif
|
||||||
|
|
||||||
type = EResType::DIRECTORY;
|
type = EResType::DIRECTORY;
|
||||||
}
|
}
|
||||||
@@ -134,7 +147,7 @@ std::unordered_map<ResourceID, bfs::path> CFilesystemLoader::listFiles(const std
|
|||||||
{
|
{
|
||||||
//reconstruct relative filename (not possible via boost AFAIK)
|
//reconstruct relative filename (not possible via boost AFAIK)
|
||||||
bfs::path filename;
|
bfs::path filename;
|
||||||
const size_t iterations = std::min((size_t)it.level(), path.size());
|
const size_t iterations = std::min(static_cast<size_t>(currentDepth), path.size());
|
||||||
if (iterations)
|
if (iterations)
|
||||||
{
|
{
|
||||||
filename = path.front();
|
filename = path.front();
|
||||||
|
@@ -33,36 +33,32 @@ void ResourceConverter::convertExtractedResourceFiles(ConversionOptions conversi
|
|||||||
|
|
||||||
void ResourceConverter::doConvertPcxToPng(bool deleteOriginals)
|
void ResourceConverter::doConvertPcxToPng(bool deleteOriginals)
|
||||||
{
|
{
|
||||||
std::string filename;
|
|
||||||
|
|
||||||
bfs::path imagesPath = VCMIDirs::get().userExtractedPath() / "IMAGES";
|
bfs::path imagesPath = VCMIDirs::get().userExtractedPath() / "IMAGES";
|
||||||
bfs::directory_iterator end_iter;
|
bfs::directory_iterator end_iter;
|
||||||
|
|
||||||
for(bfs::directory_iterator dir_itr(imagesPath); dir_itr != end_iter; ++dir_itr)
|
for(bfs::directory_iterator dir_itr(imagesPath); dir_itr != end_iter; ++dir_itr)
|
||||||
{
|
{
|
||||||
|
const auto filename = dir_itr->path().filename();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (!bfs::is_regular_file(dir_itr->status()))
|
if (!bfs::is_regular_file(dir_itr->status()))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
std::string filePath = dir_itr->path().string();
|
std::string filenameLowerCase = boost::algorithm::to_lower_copy(filename.string());
|
||||||
std::string fileStem = dir_itr->path().stem().string();
|
|
||||||
filename = dir_itr->path().filename().string();
|
|
||||||
std::string filenameLowerCase = boost::locale::to_lower(filename);
|
|
||||||
|
|
||||||
if(bfs::extension(filenameLowerCase) == ".pcx")
|
if(boost::algorithm::to_lower_copy(filename.extension().string()) == ".pcx")
|
||||||
{
|
{
|
||||||
auto img = BitmapHandler::loadBitmap(filenameLowerCase);
|
auto img = BitmapHandler::loadBitmap(filenameLowerCase);
|
||||||
bfs::path pngFilePath = imagesPath / (fileStem + ".png");
|
bfs::path pngFilePath = imagesPath / (dir_itr->path().stem().string() + ".png");
|
||||||
img.save(pathToQString(pngFilePath), "PNG");
|
img.save(pathToQString(pngFilePath), "PNG");
|
||||||
|
|
||||||
if(deleteOriginals)
|
if(deleteOriginals)
|
||||||
bfs::remove(filePath);
|
bfs::remove(dir_itr->path());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch(const std::exception & ex)
|
catch(const std::exception & ex)
|
||||||
{
|
{
|
||||||
logGlobal->info(filename + " " + ex.what() + "\n");
|
logGlobal->info(filename.string() + " " + ex.what() + "\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user