拡張子の大文字小文字を無視するようにした

This commit is contained in:
lltcggie 2015-11-19 02:34:46 +09:00
parent 6989f81f4e
commit 22bbffe1d8
2 changed files with 46 additions and 19 deletions

View File

@ -2,12 +2,14 @@
#include <windows.h> #include <windows.h>
#include <Commctrl.h> #include <Commctrl.h>
#include <tchar.h> #include <tchar.h>
#include <stdio.h>
#include <string> #include <string>
#include <thread> #include <thread>
#include <atomic> #include <atomic>
#include <chrono> #include <chrono>
#include <iostream> #include <iostream>
#include <fstream> #include <fstream>
#include <algorithm>
#include <boost/filesystem.hpp> #include <boost/filesystem.hpp>
#include <boost/tokenizer.hpp> #include <boost/tokenizer.hpp>
#include <boost/foreach.hpp> #include <boost/foreach.hpp>
@ -233,7 +235,11 @@ private:
tokenizer tokens(inputFileExt, sep); tokenizer tokens(inputFileExt, sep);
for (tokenizer::iterator tok_iter = tokens.begin(); tok_iter != tokens.end(); ++tok_iter) for (tokenizer::iterator tok_iter = tokens.begin(); tok_iter != tokens.end(); ++tok_iter)
extList.push_back("." + *tok_iter); {
std::string ext(*tok_iter);
std::transform(ext.begin(), ext.end(), ext.begin(), ::tolower);
extList.push_back("." + ext);
}
} }
if (!NotSyncCropSize) if (!NotSyncCropSize)
@ -268,7 +274,12 @@ private:
BOOST_FOREACH(const boost::filesystem::path& p, std::make_pair(boost::filesystem::recursive_directory_iterator(input_path), BOOST_FOREACH(const boost::filesystem::path& p, std::make_pair(boost::filesystem::recursive_directory_iterator(input_path),
boost::filesystem::recursive_directory_iterator())) boost::filesystem::recursive_directory_iterator()))
{ {
if (!boost::filesystem::is_directory(p) && std::find(extList.begin(), extList.end(), p.extension().string()) != extList.end())
if (!boost::filesystem::is_directory(p))
{
std::string ext(p.extension().string());
std::transform(ext.begin(), ext.end(), ext.begin(), ::tolower);
if (std::find(extList.begin(), extList.end(), ext) != extList.end())
{ {
auto mat = Waifu2x::LoadMat(p.string()); auto mat = Waifu2x::LoadMat(p.string());
if (mat.empty()) if (mat.empty())
@ -281,6 +292,7 @@ private:
} }
} }
} }
}
else else
{ {
auto mat = Waifu2x::LoadMat(input_path.string()); auto mat = Waifu2x::LoadMat(input_path.string());
@ -376,7 +388,11 @@ private:
BOOST_FOREACH(const boost::filesystem::path& p, std::make_pair(boost::filesystem::recursive_directory_iterator(path), BOOST_FOREACH(const boost::filesystem::path& p, std::make_pair(boost::filesystem::recursive_directory_iterator(path),
boost::filesystem::recursive_directory_iterator())) boost::filesystem::recursive_directory_iterator()))
{ {
if (!boost::filesystem::is_directory(p) && std::find(extList.begin(), extList.end(), p.extension().string()) != extList.end()) if (!boost::filesystem::is_directory(p))
{
std::string ext(p.extension().string());
std::transform(ext.begin(), ext.end(), ext.begin(), ::tolower);
if (std::find(extList.begin(), extList.end(), ext) != extList.end())
{ {
const auto out_relative = relativePath(p, input_path); const auto out_relative = relativePath(p, input_path);
const auto out_absolute = output_path / out_relative; const auto out_absolute = output_path / out_relative;
@ -386,6 +402,7 @@ private:
file_paths.emplace_back(p.string(), out); file_paths.emplace_back(p.string(), out);
} }
} }
}
return true; return true;
}; };

View File

@ -1,4 +1,5 @@
#include <stdio.h> #include <stdio.h>
#include <algorithm>
#include <tclap/CmdLine.h> #include <tclap/CmdLine.h>
#include <boost/filesystem.hpp> #include <boost/filesystem.hpp>
#include <boost/foreach.hpp> #include <boost/foreach.hpp>
@ -179,7 +180,11 @@ int main(int argc, char** argv)
tokenizer tokens(cmdInputFileExt.getValue(), sep); tokenizer tokens(cmdInputFileExt.getValue(), sep);
for (tokenizer::iterator tok_iter = tokens.begin(); tok_iter != tokens.end(); ++tok_iter) for (tokenizer::iterator tok_iter = tokens.begin(); tok_iter != tokens.end(); ++tok_iter)
extList.push_back("." + *tok_iter); {
std::string ext(*tok_iter);
std::transform(ext.begin(), ext.end(), ext.begin(), ::tolower);
extList.push_back("." + ext);
}
} }
// 変換する画像の入力、出力パスを取得 // 変換する画像の入力、出力パスを取得
@ -202,7 +207,11 @@ int main(int argc, char** argv)
} }
} }
} }
else if (std::find(extList.begin(), extList.end(), p.extension().string()) != extList.end()) else
{
std::string ext(p.extension().string());
std::transform(ext.begin(), ext.end(), ext.begin(), ::tolower);
if (std::find(extList.begin(), extList.end(), ext) != extList.end())
{ {
const auto out_relative = relativePath(p, input_path); const auto out_relative = relativePath(p, input_path);
const auto out_absolute = output_path / out_relative; const auto out_absolute = output_path / out_relative;
@ -212,6 +221,7 @@ int main(int argc, char** argv)
file_paths.emplace_back(p.string(), out); file_paths.emplace_back(p.string(), out);
} }
} }
}
return true; return true;
}; };