Skip to content
This repository has been archived by the owner on Mar 16, 2019. It is now read-only.

Commit

Permalink
Apply fix to #302 IOS fs.df issue
Browse files Browse the repository at this point in the history
  • Loading branch information
wkh237 committed Apr 5, 2017
1 parent a5ce44c commit 2191a6f
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions ios/RNFetchBlobFS.m
Original file line number Diff line number Diff line change
Expand Up @@ -748,20 +748,17 @@ + (void) getPathFromUri:(NSString *)uri completionHandler:(void(^)(NSString * pa

+(void) df:(RCTResponseSenderBlock)callback
{
uint64_t totalSpace = 0;
uint64_t totalFreeSpace = 0;
NSError *error = nil;
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSDictionary *dictionary = [[NSFileManager defaultManager] attributesOfFileSystemForPath:[paths lastObject] error: &error];

if (dictionary) {
NSNumber *fileSystemSizeInBytes = [dictionary objectForKey: NSFileSystemSize];
NSNumber *freeFileSystemSizeInBytes = [dictionary objectForKey:NSFileSystemFreeSize];
totalSpace = [fileSystemSizeInBytes unsignedLongLongValue];
totalFreeSpace = [freeFileSystemSizeInBytes unsignedLongLongValue];

callback(@[[NSNull null], @{
@"free" : [NSNumber numberWithUnsignedLongLong: totalFreeSpace],
@"total" : [NSNumber numberWithUnsignedLongLong: totalSpace],
@"free" : freeFileSystemSizeInBytes,
@"total" : fileSystemSizeInBytes,
}]);
} else {
callback(@[@"failed to get storage usage."]);
Expand Down

0 comments on commit 2191a6f

Please sign in to comment.