|
@@ -722,6 +722,31 @@ NSMutableDictionary *fileStreams = nil;
|
722
|
722
|
}
|
723
|
723
|
}
|
724
|
724
|
|
|
725
|
+#pragma mark - get disk space
|
|
726
|
+
|
|
727
|
++(void) df:(RCTResponseSenderBlock)callback
|
|
728
|
+{
|
|
729
|
+ uint64_t totalSpace = 0;
|
|
730
|
+ uint64_t totalFreeSpace = 0;
|
|
731
|
+ NSError *error = nil;
|
|
732
|
+ NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
|
|
733
|
+ NSDictionary *dictionary = [[NSFileManager defaultManager] attributesOfFileSystemForPath:[paths lastObject] error: &error];
|
|
734
|
+
|
|
735
|
+ if (dictionary) {
|
|
736
|
+ NSNumber *fileSystemSizeInBytes = [dictionary objectForKey: NSFileSystemSize];
|
|
737
|
+ NSNumber *freeFileSystemSizeInBytes = [dictionary objectForKey:NSFileSystemFreeSize];
|
|
738
|
+ totalSpace = [fileSystemSizeInBytes unsignedLongLongValue];
|
|
739
|
+ totalFreeSpace = [freeFileSystemSizeInBytes unsignedLongLongValue];
|
|
740
|
+ callback(@[[NSNull null], @{
|
|
741
|
+ @"free" : [NSNumber numberWithInt:totalFreeSpace],
|
|
742
|
+ @"total" : [NSNumber numberWithInt:totalSpace]
|
|
743
|
+ }]);
|
|
744
|
+ } else {
|
|
745
|
+ callback(@[@"failed to get storage usage."]);
|
|
746
|
+ }
|
|
747
|
+
|
|
748
|
+}
|
|
749
|
+
|
725
|
750
|
+ (void) writeAssetToPath:(ALAssetRepresentation * )rep dest:(NSString *)dest
|
726
|
751
|
{
|
727
|
752
|
int read = 0;
|