Merge pull request #65 from ecentinela/master

Added a method to see the cache size
This commit is contained in:
Olivier Poitrey 2012-03-10 06:01:48 -08:00
commit 6660c51d36
2 changed files with 14 additions and 0 deletions

View File

@ -28,5 +28,6 @@
- (void)clearMemory;
- (void)clearDisk;
- (void)cleanDisk;
- (int)getSize;
@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