Skip to content

Instantly share code, notes, and snippets.

@umwelt
Created May 29, 2020 14:56
Show Gist options
  • Save umwelt/fb3c50c77b8e0f15a68bb8bed931178b to your computer and use it in GitHub Desktop.
Save umwelt/fb3c50c77b8e0f15a68bb8bed931178b to your computer and use it in GitHub Desktop.
FileManager Extension
import Foundation
extension FileManager {
func urls(for directory: FileManager.SearchPathDirectory, skipsHiddenFiles: Bool = true ) -> [URL]? {
let documentsURL = urls(for: directory, in: .userDomainMask)[0]
let fileURLs = try? contentsOfDirectory(at: documentsURL, includingPropertiesForKeys: nil, options: skipsHiddenFiles ? .skipsHiddenFiles : [] )
return fileURLs
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment