Refactoring: Consolidate file deletion into a separate function

Signed-off-by: Roopesh Chander <roop@roopc.net>
This commit is contained in:
Roopesh Chander
2018-12-05 15:23:55 +05:30
parent 290bd192a0
commit f6faffa4c1
3 changed files with 16 additions and 17 deletions
@@ -16,4 +16,14 @@ extension FileManager {
}
return sharedFolderURL.appendingPathComponent("lastActivatedTunnelLog.txt")
}
static func deleteFile(at url: URL) -> Bool {
do {
try FileManager.default.removeItem(at: url)
} catch(let e) {
os_log("Failed to delete file '%{public}@': %{public}@", log: OSLog.default, type: .debug, url.absoluteString, e.localizedDescription)
return false
}
return true
}
}