Added a method to see cache size.

This commit is contained in:
Javier Martinez Fernandez 2012-02-07 11:43:29 +01:00
parent b207dcc6a8
commit e5cd63617f
2 changed files with 14 additions and 0 deletions

View File

@ -28,5 +28,6 @@
- (void)clearMemory; - (void)clearMemory;
- (void)clearDisk; - (void)clearDisk;
- (void)cleanDisk; - (void)cleanDisk;
- (int)getSize;
@end @end

View File

@ -337,4 +337,17 @@ static SDImageCache *instance;
} }
} }
-(int)getSize
{
int size = 0;
NSDirectoryEnumerator *fileEnumerator = [[NSFileManager defaultManager] enumeratorAtPath:diskCachePath];
for (NSString *fileName in fileEnumerator)
{
NSString *filePath = [diskCachePath stringByAppendingPathComponent:fileName];
NSDictionary *attrs = [[NSFileManager defaultManager] attributesOfItemAtPath:filePath error:nil];
size += [attrs fileSize];
}
return size;
}
@end @end