diff --git a/app/actions.cpp b/app/actions.cpp index b75c74af..a58d467f 100644 --- a/app/actions.cpp +++ b/app/actions.cpp @@ -1958,13 +1958,23 @@ namespace { } }; + void replace(std::string& text, const std::string& searchText, const std::string& replaceText) + { + std::string::size_type index = 0; + while ((index = text.find(searchText, index)) != std::string::npos) + { + text.replace(index, searchText.length(), replaceText.c_str(), replaceText.length()); + index++; + } + } + int renameFile(std::string& newPath, const struct tm* tm) { std::string path = newPath; std::string format = Params::instance().format_; - Util::replace(format, ":basename:", Util::basename(path, true)); - Util::replace(format, ":dirname:", Util::basename(Util::dirname(path))); - Util::replace(format, ":parentname:", Util::basename(Util::dirname(Util::dirname(path)))); + replace(format, ":basename:", Util::basename(path, true)); + replace(format, ":dirname:", Util::basename(Util::dirname(path))); + replace(format, ":parentname:", Util::basename(Util::dirname(Util::dirname(path)))); const size_t max = 1024; char basename[max]; diff --git a/src/utils.cpp b/src/utils.cpp index 20f05bbd..0ef0f203 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -109,13 +109,4 @@ namespace Util { return true; } - void replace(std::string& text, const std::string& searchText, const std::string& replaceText) - { - std::string::size_type index = 0; - while ((index = text.find(searchText, index)) != std::string::npos) - { - text.replace(index, searchText.length(), replaceText.c_str(), replaceText.length()); - index++; - } - } } // namespace Util diff --git a/src/utils.hpp b/src/utils.hpp index 3a23099a..5f63b7d5 100644 --- a/src/utils.hpp +++ b/src/utils.hpp @@ -70,13 +70,6 @@ namespace Util { n is not modified if the conversion is unsuccessful. See strtol(2). */ bool strtol(const char* nptr, long& n); - - /*! - @brief Replaces all occurrences of \em searchText in the \em text string - by \em replaceText. - */ - void replace(std::string& text, const std::string& searchText, const std::string& replaceText); - } // namespace Util #endif // #ifndef UTILS_HPP_