27 lines
1.1 KiB
Swift
27 lines
1.1 KiB
Swift
/// A type that interfaces with the local file system.
|
|
protocol FileServicing: Sendable {
|
|
|
|
// MARK: Functions
|
|
|
|
/// Lists the names of items located at a given folder path. in the local file system.
|
|
/// - 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)
|
|
}
|