MCPcopy Create free account
hub / github.com/FreeCAD/FreeCAD / replaceProjectFile

Method replaceProjectFile

src/App/ProjectFile.cpp:855–883  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

853}
854
855bool ProjectFile::replaceProjectFile(const std::string& name, bool keepfile)
856{
857 std::string uuid = Base::Uuid::createUuid();
858 std::string fn = stdFile;
859 fn += ".";
860 fn += uuid;
861
862 // Now rename the original file to something unique
863 Base::FileInfo orig(stdFile);
864 if (!orig.renameFile(fn.c_str())) {
865 return false;
866 }
867 orig.setFile(fn);
868
869 // rename the tmp.file to the original file name
870 Base::FileInfo other(name);
871 if (!other.renameFile(stdFile.c_str())) {
872 return false;
873 }
874
875 // and delete the renamed original file.
876 if (!keepfile) {
877 if (!orig.deleteFile()) {
878 return false;
879 }
880 }
881
882 return true;
883}

Callers

nothing calls this directly

Calls 4

renameFileMethod · 0.80
c_strMethod · 0.45
setFileMethod · 0.45
deleteFileMethod · 0.45

Tested by

no test coverage detected