* Empty Binary Directory */
| 50 | * Empty Binary Directory |
| 51 | */ |
| 52 | bool EmptyBinaryDirectory(std::string const& sname, std::string& err) |
| 53 | { |
| 54 | // try to avoid deleting root |
| 55 | if (sname.size() < 2) { |
| 56 | err = "path too short"; |
| 57 | return false; |
| 58 | } |
| 59 | |
| 60 | // consider non existing target directory a success |
| 61 | if (!cmSystemTools::FileExists(sname)) { |
| 62 | return true; |
| 63 | } |
| 64 | |
| 65 | // try to avoid deleting directories that we shouldn't |
| 66 | std::string check = cmStrCat(sname, "/CMakeCache.txt"); |
| 67 | |
| 68 | if (!cmSystemTools::FileExists(check)) { |
| 69 | err = "path does not contain an existing CMakeCache.txt file"; |
| 70 | return false; |
| 71 | } |
| 72 | |
| 73 | cmsys::Status status; |
| 74 | for (int i = 0; i < 5; ++i) { |
| 75 | status = TryToRemoveBinaryDirectoryOnce(sname); |
| 76 | if (status) { |
| 77 | return true; |
| 78 | } |
| 79 | cmSystemTools::Delay(100); |
| 80 | } |
| 81 | |
| 82 | err = status.GetString(); |
| 83 | return false; |
| 84 | } |
| 85 | |
| 86 | } // namespace |
| 87 |
no test coverage detected
searching dependent graphs…