Skip to content

eonist/FileStreamer

Repository files navigation

Lang mit Tests

FileStreamer

Continuous data to disk

Installation:

  • SPM "https://github.com/light-stream/FileStreamer.git" branch: "master"

Writer example:

let filePath: String = NSString(string: "~/Desktop/del.txt").expandingTildeInPath
guard let data: Data = ("black dog" as NSString).data(using: String.Encoding.utf8.rawValue) else {Swift.print("unable to create data");return}
FSWriter.write(url: URL(filePath), data: data, index: 0)

Reader example:

let filePath: String = NSString(string: "~/Desktop/del.txt").expandingTildeInPath
let data: Data = FSReader.read(filePath: filePath, startIndex: 50, endIndex: 100)
Swift.print("\(String(data: data, encoding: .utf8))") // blalbslalballabalbla...

Size example:

let fileSize = FSReader.fileSize(filePath: filePath)