Created
July 21, 2017 20:07
-
-
Save staycreativedesign/337fadea25362d0be8e5d964a20e3189 to your computer and use it in GitHub Desktop.
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
func checkForDecksDirectory() { | |
let fm = FileManager.default | |
let dirPath = fm.urls(for: .documentDirectory, in: .userDomainMask) | |
let docsURL = dirPath[0] | |
let docPath = docsURL.appendingPathComponent("decks").absoluteString | |
let deckPath = docsURL.appendingPathComponent("decks") | |
var isDir : ObjCBool = false | |
if fm.fileExists(atPath: docPath, isDirectory:&isDir) { | |
if isDir.boolValue { | |
// file exists and is a directory | |
print("file exists is a dir") | |
} else { | |
// file exists and is not a directory | |
print("file exists is not a dir") | |
} | |
} else { | |
do { | |
try fm.createDirectory(at: deckPath, withIntermediateDirectories: true, attributes: nil) | |
} | |
catch { | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment