CocoaPods 是 iOS 项目的库管理器。要使用 CocoaPods 安装
pod 'Filer'
mkdir
touch
ls
rm
/ rmdir
mv
cp
exists
/ test
cat
du
Filer.mkdir(.Temp, dirName: "hoge") // create directory
Filer.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") // true
File(.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") // true
File(.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() // -> UIImage
jsonString --> 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!"
支持目录 | 描述 |
---|---|
.Temp | 临时目录 |
.Home | 主目录 |
.Document | 文档目录 |
.Cache | 缓存目录 |
.Library | 库目录 |
.Inbox | 收件箱目录 |
MIT 许可证