mirror of
https://github.com/ninxsoft/Mist.git
synced 2025-05-21 10:45:27 -04:00
24 lines
774 B
Swift
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)
|
|
}
|
|
}
|