Implemented the "delete(at: )" function for the FileService service in the module target.

This commit is contained in:
2025-01-11 04:44:02 +01:00
parent 7d0ad3461a
commit 58151a4e5a
3 changed files with 44 additions and 2 deletions
@@ -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