* We generally don't overwrite files without backup before */
| 186 | * We generally don't overwrite files without backup before |
| 187 | */ |
| 188 | bool NodeUtility::CreateBackupFile(const String& target, bool isPrivate) |
| 189 | { |
| 190 | if (!Utility::PathExists(target)) |
| 191 | return false; |
| 192 | |
| 193 | String backup = target + ".orig"; |
| 194 | |
| 195 | if (Utility::PathExists(backup)) { |
| 196 | Log(LogInformation, "cli") |
| 197 | << "Backup file '" << backup << "' already exists. Skipping backup."; |
| 198 | return false; |
| 199 | } |
| 200 | |
| 201 | Utility::CopyFile(target, backup); |
| 202 | |
| 203 | #ifndef _WIN32 |
| 204 | if (isPrivate) |
| 205 | chmod(backup.CStr(), 0600); |
| 206 | #endif /* _WIN32 */ |
| 207 | |
| 208 | Log(LogInformation, "cli") |
| 209 | << "Created backup file '" << backup << "'."; |
| 210 | |
| 211 | return true; |
| 212 | } |
| 213 | |
| 214 | void NodeUtility::SerializeObject(std::ostream& fp, const Dictionary::Ptr& object) |
| 215 | { |
nothing calls this directly
no test coverage detected