| 853 | } |
| 854 | |
| 855 | bool 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 | } |
nothing calls this directly
no test coverage detected