MCPcopy Create free account
hub / github.com/LBANN/lbann / modify_file_name

Function modify_file_name

src/utils/file_utils.cpp:142–166  ·  view source on GitHub ↗

* 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. */

Source from the content-addressed store, hash-verified

140 * the extension without adding a tag, set tag to a null string.
141 */
142std::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.
169bool check_if_file_exists(const std::string& filename)

Callers

nothing calls this directly

Calls 5

parse_pathFunction · 0.85
get_ext_nameFunction · 0.85
get_basename_without_extFunction · 0.85
add_delimiterFunction · 0.85
emptyMethod · 0.45

Tested by

no test coverage detected