From e5cd63617f7eb9534a70a35665038bd0670ba3f5 Mon Sep 17 00:00:00 2001 From: Javier Martinez Fernandez Date: Tue, 7 Feb 2012 11:43:29 +0100 Subject: [PATCH] Added a method to see cache size. --- SDImageCache.h | 1 + SDImageCache.m | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/SDImageCache.h b/SDImageCache.h index f2abd120..7969dd3d 100644 --- a/SDImageCache.h +++ b/SDImageCache.h @@ -28,5 +28,6 @@ - (void)clearMemory; - (void)clearDisk; - (void)cleanDisk; +- (int)getSize; @end diff --git a/SDImageCache.m b/SDImageCache.m index 44671b88..c0d7d273 100644 --- a/SDImageCache.m +++ b/SDImageCache.m @@ -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