Commit d84d1e50 authored by Mathieu Giraud's avatar Mathieu Giraud

core/tools.{cpp,h}: extract_dirname

parent d07b875a
......@@ -178,6 +178,16 @@ string extract_from_label(string str, int field, string separator)
return str.substr(found1+1, found2-found1-1);
}
string extract_dirname(string path) {
size_t pos_lastdir = path.find_last_of('/');
if (pos_lastdir != std::string::npos) {
path = path.substr(0, pos_lastdir);
}
return path;
}
string extract_basename(string path, bool remove_ext) {
size_t pos_lastdir = path.find_last_of('/');
if (pos_lastdir != std::string::npos) {
......
......@@ -120,7 +120,12 @@ int dna_to_int(const string &, int size);
string extract_from_label(string str, int field, string separator);
/**
* @return Extract basename of a file and extracts extension (by default
* @return Extract dirname of a file
*/
string extract_dirname(string path);
/**
* @return Extract basename of a file and extracts extension (by default)
*/
string extract_basename(string path, bool remove_ext = true);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment