* Add tag to a file name and/or change the extension. * i.e., given a file_name as "name.ext", a new name "name_tag.new_ext" is * returned If a new extension is not specified, it assumes the same. To change * the extension without adding a tag, set tag to a null string. */
| 140 | * the extension without adding a tag, set tag to a null string. |
| 141 | */ |
| 142 | std::string modify_file_name(const std::string file_name, |
| 143 | const std::string tag, |
| 144 | const std::string new_ext) |
| 145 | { |
| 146 | std::string dir; |
| 147 | std::string name; |
| 148 | bool ok = parse_path(file_name, dir, name); |
| 149 | if (!ok) { |
| 150 | return std::string(); |
| 151 | } |
| 152 | std::string ext = (new_ext.empty() ? get_ext_name(name) : new_ext); |
| 153 | name = get_basename_without_ext(name); |
| 154 | |
| 155 | if (!tag.empty()) { |
| 156 | name = name + '_' + tag; |
| 157 | } |
| 158 | |
| 159 | dir = add_delimiter(dir); |
| 160 | if (!ext.empty()) { |
| 161 | return (dir + name + '.' + ext); |
| 162 | } |
| 163 | else { |
| 164 | return (dir + name); |
| 165 | } |
| 166 | } |
| 167 | |
| 168 | /// @todo Deprecated. |
| 169 | bool check_if_file_exists(const std::string& filename) |
nothing calls this directly
no test coverage detected