Implemented the "delete(at: )" function for the FileService service in the module target.
This commit is contained in:
@@ -20,6 +20,20 @@ public struct FileService: FileServicing {
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: Functions
|
||||
|
||||
public func delete(at url: URL) async throws (FileServiceError) {
|
||||
guard try await exists(at: url) else {
|
||||
throw FileServiceError.urlNotExists
|
||||
}
|
||||
|
||||
do {
|
||||
try fileManager.removeItem(at: url)
|
||||
} catch {
|
||||
throw FileServiceError.urlNotDeleted
|
||||
}
|
||||
}
|
||||
|
||||
public func exists(at url: URL) async throws (FileServiceError) -> Bool {
|
||||
guard url.isFileURL else {
|
||||
throw FileServiceError.urlNotFileURL
|
||||
|
||||
Reference in New Issue
Block a user