INNER CODE UNIT · Swift

directoryExists

a2/swift-shortcuts · Playground/GeneratePlayground.swift:5

    func directoryExists(at url: URL) -> Bool {
        var isDirectory: ObjCBool = false
        return fileExists(atPath: url.path, isDirectory: &isDirectory) && isDirectory.boolValue
    }
}

let fileManager = FileManager.default
let isDebuggable = UserDefaults.standard.bool(forKey: "debug") // use -debug

// Get the Playgrounds directory
let playgroundsDirectory = URL(fileURLWithPath: fileManager.currentDirectoryPath)
    .appendingPathComponent(CommandLine.arguments[0])
    .deletingLastPathComponent()

// Read the version from the arguments
let version = UserDefaults.standard.string(forKey: "version") ?? ""
if version.isEmpty {
    print("Specify version using -version argument")

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…