Defined the FileServicing protocol in the library target.

This commit is contained in:
Javier Cicchelli 2025-03-11 22:46:20 +01:00
parent 16712821d8
commit f6dcc80edc

View File

@ -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)
}