diff --git a/BaseLib/FileTools.cpp b/BaseLib/FileTools.cpp index 81b02ea4bb3351e8e240df3d794cc07d4aea23ca..821ea0f92635de2115c07160ab40dd1bc7b42725 100644 --- a/BaseLib/FileTools.cpp +++ b/BaseLib/FileTools.cpp @@ -17,6 +17,7 @@ #include <sys/stat.h> #include <boost/filesystem.hpp> +#include <boost/algorithm/string.hpp> namespace BaseLib { @@ -116,10 +117,7 @@ std::string getFileExtension(const std::string &path) bool hasFileExtension(std::string const& extension, std::string const& filename) { - std::string ext = stringToUpper(extension); // Copy for modification. - std::string file_ext = stringToUpper(getFileExtension(filename)); - - return ext == file_ext; + return boost::iequals(extension, getFileExtension(filename)); } std::string copyPathToFileName(const std::string &file_name, diff --git a/BaseLib/FileTools.h b/BaseLib/FileTools.h index 2ff36669be3ddbb2f05221311b4a00af43327432..feac59e53a791961aa4c839d23d726416d744a37 100644 --- a/BaseLib/FileTools.h +++ b/BaseLib/FileTools.h @@ -129,8 +129,7 @@ std::string getFileExtension(std::string const& filename); /** * Compares filename's extension with query extension. The comparison is case - * insensitive done by converting to upper case with the std::toupper() - * function. + * insensitive. */ bool hasFileExtension(std::string const& extension, std::string const& filename); diff --git a/BaseLib/StringTools.cpp b/BaseLib/StringTools.cpp index 3fc1f3e670228065caf412e510d3be428a983998..7e78d9e3da8a1395b4e1809cc71a6eecd2a3daf5 100644 --- a/BaseLib/StringTools.cpp +++ b/BaseLib/StringTools.cpp @@ -72,13 +72,6 @@ void simplify(std::string &str) ); } -std::string stringToUpper(std::string const& str) -{ - std::string s = str; - std::transform(s.begin(), s.end(), s.begin(), (int(*)(int)) std::toupper); - return s; -} - std::string padLeft(std::string const& str, int maxlen, char ch) { std::stringstream ss(str); diff --git a/BaseLib/StringTools.h b/BaseLib/StringTools.h index 521858dba17f02240169dbcbb35f3961ba96271f..19704d26369021c91a2478aab6223c3ff110e053 100644 --- a/BaseLib/StringTools.h +++ b/BaseLib/StringTools.h @@ -22,7 +22,6 @@ #include <sstream> #include <fstream> #include <iostream> -#include <ctype.h> namespace BaseLib { @@ -69,13 +68,6 @@ void trim(std::string &str, char ch=' '); */ void simplify(std::string &str); -/** - * Returns same string with all characters in upper case. - * - * This uses std::toupper() function, and does not care about unicode. - */ -std::string stringToUpper(std::string const& str); - /** * Returns the string which is right aligned with padding on the left. */