- Super easily handle file(copy, move, delete, test, ls...)
- Supports write/read Text and NSData
- Supports write/read UIImage(png, jpg)
CocoaPods is a library manager for iOS projects. To install using CocoaPods:
pod 'Filer'
mkdirtouchlsrm/rmdirmvcpexists/testcatdu
Filer.mkdir(.Temp, dirName: "hoge") // create directoryFiler.touch(.Temp, path: "hoge.txt")
Filer.touch(.Temp, path: "fuga.txt")
Filer.ls(.Temp) // [File ("hoge.txt"), File ("fuga.txt")]Filer.mkdir(.Temp, "hoge")
Filer.touch(.Temp, "hoge/test.txt")
Filer.rm(.Temp, "hoge/test.txt")
Filer.rmdir(.Temp, "hoge")File(.Document, path: "hoge.txt").write("Awesome!")
Filer.mv(.Document, srcPath: "hoge.txt", "fuga.txt")
Filer.test(.Document, path: "hoge.txt") // false
Filer.test(.Document, path: "fuga.txt") // trueFile(.Document, path: "hoge.txt").write("Awesome!")
Filer.cp(.Document, srcPath: "hoge.txt", toPath: "fuga.txt")
Filer.exists(.Document, path: "hoge.txt") // true
Filer.exists(.Document, path: "fuga.txt") // trueFile(.Document, path: "hoge.txt").write("Awesome!")
Filer.cat(.Document, path: "hoge.txt") // "Awesome!"Filer.du(.Document, path: "hoge.txt") // file size(bytes)let file = File(.Document, path: "sample.txt")
file.write("Awesome!") // write text
file.append("Wow!") // append string
file.read() // "Awesome!Wow!"
File(.Document, path: "sampleImage.png").writeImage(image, .Png) // write png
File(.Document, path: "sampleImage.jpg").writeImage(image, .Jpeg(0.8)) // write jpeg(quality: 0~1.0)
File(.document, path: "sampleImage.png").readImage() // -> UIImagejsonString --> File(.Document, path: "internal.json") // write text
let thumbnail = File(.Document, path: "thumbnail.png")
UIImagePNGRepresentation(image) --> thumbnail // write NSData
let file = File(.Document, path: "sample.txt")
file.write("Awesome!")
"Beautiful!" ->> file // append
file.read() // "Awesome!Beautiful!"| Supported Directory | description |
|---|---|
| .Temp | Temporary directory |
| .Home | Home direcotry |
| .Document | Document directory |
| .Cache | Cache direcotry |
| .Library | Library directory |
| .Inbox | Inbox directory |
- Xcode 6.3
- Swift 1.2 or above
MIT License
