Mist/Mist/Helpers/DirectoryCreator.swift
2022-07-01 20:29:18 +10:00

24 lines
774 B
Swift

//
// DirectoryCreator.swift
// Mist
//
// Created by Nindi Gill on 21/6/2022.
//
import Foundation
/// Helper struct to create directories.
struct DirectoryCreator {
/// Create a directory at the provided URL.
///
/// - Parameters:
/// - url: The URL of the directory to create.
/// - withIntermediateDirectories: Set to `true` to create all intermediate directories.
///
/// - Throws: An `Error` if the command failed to execute.
static func create(_ url: URL, withIntermediateDirectories: Bool = false) async throws {
try await DirectoryRemover.remove(url)
try FileManager.default.createDirectory(at: url, withIntermediateDirectories: withIntermediateDirectories, attributes: nil)
}
}