Created
June 11, 2017 22:06
-
-
Save richbs/0bbdf1a1b407122241220e3f2d1c1800 to your computer and use it in GitHub Desktop.
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
//: 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