From f6dcc80edcef20b222fa929743fa4aa2efab487c Mon Sep 17 00:00:00 2001 From: Javier Cicchelli Date: Tue, 11 Mar 2025 22:46:20 +0100 Subject: [PATCH] Defined the FileServicing protocol in the library target. --- .../Internal/Protocols/FileServicing.swift | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 Library/Sources/Internal/Protocols/FileServicing.swift diff --git a/Library/Sources/Internal/Protocols/FileServicing.swift b/Library/Sources/Internal/Protocols/FileServicing.swift new file mode 100644 index 0000000..39bd4d8 --- /dev/null +++ b/Library/Sources/Internal/Protocols/FileServicing.swift @@ -0,0 +1,26 @@ +/// A type that services access to information from the local file system. +protocol FileServicing: Sendable { + + // MARK: Functions + + /// Lists the names of items located at a given folder. path + /// - Parameter folder: A path to a folder that could be found in the local file system. + /// - Returns: A list of names related to the items retrieved from a given folder path. + /// - Throws: A ``FileServiceError`` error type in case any error happens while retrieving the list. + func listItems(in folder: String) async throws (FileServiceError) -> [String] + +} + +// MARK: - Errors + +/// A representation of all possible errors that could be returned by the type conforming to the ``FileServicing`` protocol. +enum FileServiceError: Error { + /// A given folder path is empty. + case folderPathEmpty + /// A given folder path is not actually a directory. + case folderNotDirectory + /// A given folder path has not been found in the file system. + case folderNotFound + /// Captures any other error found while executing a file service operation. + case other(Error) +}