Skip to content

Instantly share code, notes, and snippets.

@RuiNelson
Created August 22, 2018 18:01
Show Gist options
  • Save RuiNelson/57b6428b4301ab69cc8341303f0ff10c to your computer and use it in GitHub Desktop.
Save RuiNelson/57b6428b4301ab69cc8341303f0ff10c to your computer and use it in GitHub Desktop.
Check if path is a directory in Swift 4.x
import Foundation
extension FileManager {
func isDirectory(atPath: String) -> Bool {
var check: ObjCBool = false
if fileExists(atPath: atPath, isDirectory: &check) {
return check.boolValue
} else {
return false
}
}
}
// Usage:
// FileManager.default.isDirectory(atPath: "/my/path")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment