|
@@ -72,5 +72,51 @@ class NCUtilityFileSystem: NSObject {
|
|
|
} catch { }
|
|
|
return nil
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ func getFileDataInChunks() {
|
|
|
+
|
|
|
+ let doumentDirectoryPath = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true)[0] as NSString
|
|
|
+ let filePath = doumentDirectoryPath.appendingPathComponent("video.mp4")
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ if FileManager.default.fileExists(atPath: filePath) {
|
|
|
+
|
|
|
+ let chunkSize = 1024
|
|
|
+
|
|
|
+
|
|
|
+ let ReadData = NSMutableData()
|
|
|
+
|
|
|
+ do {
|
|
|
+
|
|
|
+
|
|
|
+ let outputFileHandle = try FileHandle(forReadingFrom: URL(fileURLWithPath: filePath))
|
|
|
+
|
|
|
+
|
|
|
+ var datas = outputFileHandle.readData(ofLength: chunkSize)
|
|
|
+
|
|
|
+
|
|
|
+ while !(datas.isEmpty) {
|
|
|
+
|
|
|
+
|
|
|
+ ReadData.append(datas)
|
|
|
+
|
|
|
+
|
|
|
+ datas = outputFileHandle.readData(ofLength: chunkSize)
|
|
|
+
|
|
|
+ print("Running: \(ReadData.length)")
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ outputFileHandle.closeFile()
|
|
|
+
|
|
|
+ print("File reading complete")
|
|
|
+
|
|
|
+ }catch let error as NSError {
|
|
|
+ print("Error : \(error.localizedDescription)")
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|