-
-
Save brennanMKE/a0a2ee6aa5a2e2e66297c580c4df0d66 to your computer and use it in GitHub Desktop.
fileprivate func directoryExistsAtPath(_ path: String) -> Bool { | |
var isDirectory = ObjCBool(true) | |
let exists = FileManager.default.fileExists(atPath: path, isDirectory: &isDirectory) | |
return exists && isDirectory.boolValue | |
} |
is fileExists case-insensitive? It considers "test" and "Test" as different folders. Any way to fix this?
@venkat20390, fileExists
must conform to the way OS file system treats folders.
If test
and Test
are different folders on file system - then FileManager
should treat them as different folders
@yarodevuci , I'm assuming this fileExists function does two things, it returns if given path is present and will update boolean using poiter to its address if the provided path is Directory to True else False.
Hence we are doing exists && isDirectory.boolValue in the end.
from documentation:
isDirectory: Upon return, contains true if path is a directory or if the final path element is a symbolic link that points to a directory; otherwise, contains false. If path doesn’t exist, this value is undefined upon return. Pass NULL if you do not need this information.
@yarodevuci In Swift there are no pointers and this function requires a pointer to a boolean value. This can be done using ObjCBool instead of the usual Bool type. See Apple docs for details.