1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-24 22:14:36 +02:00

fix Boost deprecation warnings

warnings introduced in v1.81

# Conflicts:
#	mapeditor/resourceExtractor/ResourceConverter.cpp
This commit is contained in:
Andrey Filipenkov 2023-01-14 16:27:11 +03:00 committed by Ivan Savenko
parent efbed6000b
commit 2f14914120
3 changed files with 23 additions and 14 deletions

View File

@ -1702,7 +1702,7 @@ int CPlayerInterface::getLastIndex( std::string namePrefix)
else
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();
if (starts_with(name, namePrefix) && ends_with(name, ".vcgm1"))

View File

@ -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
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);
#endif
for(; it != enddir; ++it)
{
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()))
{
path.resize(it.level() + 1);
path.resize(currentDepth + 1);
path.back() = it->path().filename();
// 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;
}
@ -134,7 +147,7 @@ std::unordered_map<ResourceID, bfs::path> CFilesystemLoader::listFiles(const std
{
//reconstruct relative filename (not possible via boost AFAIK)
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)
{
filename = path.front();

View File

@ -33,36 +33,32 @@ void ResourceConverter::convertExtractedResourceFiles(ConversionOptions conversi
void ResourceConverter::doConvertPcxToPng(bool deleteOriginals)
{
std::string filename;
bfs::path imagesPath = VCMIDirs::get().userExtractedPath() / "IMAGES";
bfs::directory_iterator end_iter;
for(bfs::directory_iterator dir_itr(imagesPath); dir_itr != end_iter; ++dir_itr)
{
const auto filename = dir_itr->path().filename();
try
{
if (!bfs::is_regular_file(dir_itr->status()))
return;
std::string filePath = dir_itr->path().string();
std::string fileStem = dir_itr->path().stem().string();
filename = dir_itr->path().filename().string();
std::string filenameLowerCase = boost::locale::to_lower(filename);
std::string filenameLowerCase = boost::algorithm::to_lower_copy(filename.string());
if(bfs::extension(filenameLowerCase) == ".pcx")
if(boost::algorithm::to_lower_copy(filename.extension().string()) == ".pcx")
{
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");
if(deleteOriginals)
bfs::remove(filePath);
bfs::remove(dir_itr->path());
}
}
catch(const std::exception & ex)
{
logGlobal->info(filename + " " + ex.what() + "\n");
logGlobal->info(filename.string() + " " + ex.what() + "\n");
}
}
}