Created
July 21, 2015 11:26
-
-
Save victorchee/5be478c25d1d0f659d13 to your computer and use it in GitHub Desktop.
Print Directory Content
This file contains 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 printDirectoryContent(path: String) { | |
let contents = NSFileManager.defaultManager().contentsOfDirectoryAtPath(path, error: nil) | |
if let files = contents { | |
for file in files as! [String] { | |
let filePath = path.stringByAppendingPathComponent(file) | |
let attributes = NSFileManager.defaultManager().attributesOfItemAtPath(filePath, error: nil)! | |
if attributes[NSFileType] as! String == NSFileTypeDirectory { | |
printDirectoryContent(filePath) | |
} else { | |
if NSFileManager.defaultManager().isUbiquitousItemAtURL(NSURL(fileURLWithPath: filePath)!) { | |
println(filePath) | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment