diff --git a/Library/Sources/Internal/Services/FileService.swift b/Library/Sources/Internal/Services/FileService.swift new file mode 100644 index 0000000..821aa44 --- /dev/null +++ b/Library/Sources/Internal/Services/FileService.swift @@ -0,0 +1,31 @@ +import Foundation + +struct FileService: FileServicing { + + // MARK: Functions + + func listItems(in folder: String) async throws (FileServiceError) -> [String] { + let fileManager = FileManager.default + + guard !folder.isEmpty else { + throw .folderPathEmpty + } + + var isFolder: ObjCBool = false + + guard fileManager.fileExists(atPath: folder, isDirectory: &isFolder) else { + throw .folderNotFound + } + + guard isFolder.boolValue else { + throw .folderNotDirectory + } + + do { + return try fileManager.contentsOfDirectory(atPath: folder) + } catch { + throw .other(error) + } + } + +} diff --git a/Test/Sources/Cases/Internal/Services/FileServiceTests.swift b/Test/Sources/Cases/Internal/Services/FileServiceTests.swift new file mode 100644 index 0000000..ec17adb --- /dev/null +++ b/Test/Sources/Cases/Internal/Services/FileServiceTests.swift @@ -0,0 +1,7 @@ +import Testing + +@testable import DoxyLibrary + +@Suite("FileService", .tags(.service)) +struct FileServiceTests { +} diff --git a/Test/Sources/Helpers/Extensions/Tag+Definitions.swift b/Test/Sources/Helpers/Extensions/Tag+Definitions.swift index 5948593..f7ec925 100644 --- a/Test/Sources/Helpers/Extensions/Tag+Definitions.swift +++ b/Test/Sources/Helpers/Extensions/Tag+Definitions.swift @@ -8,5 +8,6 @@ extension Tag { @Tag static var enumeration: Tag @Tag static var middleware: Tag @Tag static var provider: Tag + @Tag static var service: Tag }