NSString *cachesPath = [NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) lastObject];
NSFileManager *mgr = [NSFileManager defaultManager];
//计算caches目录大小
long long totalSize = 0;
NSArray *subpaths = [mgr subpathsAtPath:cachesPath];
for (NSString *subpath in subpaths) {
NSString *fullpath = [cachesPath stringByAppendingPathComponent:subpath];
BOOL dir = NO;
[mgr fileExistsAtPath:fullpath isDirectory:&dir];
if (dir == NO) { //文件
totalSize += [[mgr attributesOfItemAtPath:fullpath error:nil][NSFileSize] longLongValue];
}
}
NSLog(@"Libray/Caches目录的文件大小:%lld",totalSize);