Created
August 22, 2018 18:01
-
-
Save RuiNelson/57b6428b4301ab69cc8341303f0ff10c to your computer and use it in GitHub Desktop.
Check if path is a directory in Swift 4.x
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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