Skip to content

Instantly share code, notes, and snippets.

@richbs
Created June 11, 2017 22:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save richbs/0bbdf1a1b407122241220e3f2d1c1800 to your computer and use it in GitHub Desktop.
Save richbs/0bbdf1a1b407122241220e3f2d1c1800 to your computer and use it in GitHub Desktop.
//: Playground - noun: a place where people can play
import Cocoa
var str = "Hello, playground"
print(str);
let cwd = FileManager.default.currentDirectoryPath
let fm = FileManager.default
// let desktopUrl = fm.urls(for: .desktopDirectory, in: .userDomainMask).first
let dt = try! fm.url(for: .desktopDirectory, in: .userDomainMask, appropriateFor: nil, create: true)
let projectDirectory = dt.appendingPathComponent("compare")
let dirpath:String = projectDirectory.path
do {
let filelist = try fm.contentsOfDirectory(atPath: dirpath)
for filename in filelist {
//reading
let f = projectDirectory.appendingPathComponent(filename)
if (f.path.contains("json")) {
do {
let text = try String(contentsOf: f, encoding: String.Encoding.utf8)
print(text)
}
catch {/* error handling here */}
}
}
} catch let error {
print("Error: \(error.localizedDescription)")
}
let dirPaths = fm.urls(for: .documentDirectory, in: .userDomainMask)
print(dt)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment