MCPcopy Create free account
hub / github.com/computationalpathologygroup/ASAP / renameFile

Function renameFile

core/filetools.cpp:234–247  ·  view source on GitHub ↗

---------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

232
233//---------------------------------------------------------------------------
234 bool renameFile(const std::string &source, const std::string &target)
235 {
236 //checks are inserted here, because rename may throw...
237 std::string s(source), t(target);
238 cleanFileName(s);
239 cleanFileName(t);
240 if (!fileExists(s)) return false;
241 if (fileExists(t)) return false;
242 std::string dir = extractFilePath(t);
243 createDirectory(dir);
244 //BvG: if target is on a different drive, source will also be deleted
245 rename(fs::path(s), fs::path(t));
246 return fileExists(t);
247 }
248
249//---------------------------------------------------------------------------
250 std::string upOneLevel(const std::string &name)

Callers

nothing calls this directly

Calls 4

cleanFileNameFunction · 0.85
fileExistsFunction · 0.85
extractFilePathFunction · 0.85
createDirectoryFunction · 0.85

Tested by

no test coverage detected