replace is only used in actions.cpp

main
Luis Díaz Más 3 years ago committed by Luis Diaz
parent 49fbfb44a3
commit 8c6e22e6aa

@ -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) int renameFile(std::string& newPath, const struct tm* tm)
{ {
std::string path = newPath; std::string path = newPath;
std::string format = Params::instance().format_; std::string format = Params::instance().format_;
Util::replace(format, ":basename:", Util::basename(path, true)); replace(format, ":basename:", Util::basename(path, true));
Util::replace(format, ":dirname:", Util::basename(Util::dirname(path))); replace(format, ":dirname:", Util::basename(Util::dirname(path)));
Util::replace(format, ":parentname:", Util::basename(Util::dirname(Util::dirname(path)))); replace(format, ":parentname:", Util::basename(Util::dirname(Util::dirname(path))));
const size_t max = 1024; const size_t max = 1024;
char basename[max]; char basename[max];

@ -109,13 +109,4 @@ namespace Util {
return true; 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 } // namespace Util

@ -70,13 +70,6 @@ namespace Util {
n is not modified if the conversion is unsuccessful. See strtol(2). n is not modified if the conversion is unsuccessful. See strtol(2).
*/ */
bool strtol(const char* nptr, long& n); 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 } // namespace Util
#endif // #ifndef UTILS_HPP_ #endif // #ifndef UTILS_HPP_

Loading…
Cancel
Save