- (float)getTotalDiskSpace
{
float totalSpace;
NSError * error;
NSDictionary * infoDic = [[NSFileManager defaultManager] attributesOfFileSystemForPath:[self getHomeDirectory] error: &error];
if (infoDic) {
NSNumber * fileSystemSizeInBytes = [infoDic objectForKey: NSFileSystemSize];
totalSpace = [fileSystemSizeInBytes floatValue]/1024.0f/1024.0f/1024.0f;
return totalSpace;
} else {
NSLog(@"Error Obtaining System Memory Info: Domain = %@, Code = %ld", [error domain], (long)[error code]);
return 0;
}
}
- (NSString *)getHomeDirectory
{
NSString * homePath = NSHomeDirectory();
return homePath;
}
时间: 2024-10-19 12:33:40