colibri/Library/Sources/Public/Tasks/CreateFoldersTask.swift

26 lines
547 B
Swift
Raw Normal View History

import Foundation
public struct CreateFoldersTask {
// MARK: Properties
private let fileService: FileServicing
// MARK: Initialisers
public init(fileService: FileServicing) {
self.fileService = fileService
}
// MARK: Functions
public func callAsFunction(at rootFolder: URL) async throws {
let folders = Folder.allCases.map { rootFolder.appendingPath($0.path) }
for folder in folders {
try await fileService.createFolder(at: folder)
}
}
}