From e6c0f56d1f001253fa70e10c226b7effb07e6bc6 Mon Sep 17 00:00:00 2001 From: Bogdan Poplauschi Date: Sun, 15 Jun 2014 22:23:48 +0300 Subject: [PATCH] Exposed cache paths - fixes #339 --- SDWebImage/SDImageCache.h | 19 +++++++++++++++++++ SDWebImage/SDImageCache.m | 4 ++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/SDWebImage/SDImageCache.h b/SDWebImage/SDImageCache.h index 83fc4863..b713adea 100644 --- a/SDWebImage/SDImageCache.h +++ b/SDWebImage/SDImageCache.h @@ -202,4 +202,23 @@ typedef void(^SDWebImageQueryCompletedBlock)(UIImage *image, SDImageCacheType ca */ - (BOOL)diskImageExistsWithKey:(NSString *)key; +/** + * Get the cache path for a certain key (needs the cache path root folder) + * + * @param key the key (can be obtained from url using cacheKeyForURL) + * @param path the cach path root folder + * + * @return the cache path + */ +- (NSString *)cachePathForKey:(NSString *)key inPath:(NSString *)path; + +/** + * Get the default cache path for a certain key + * + * @param key the key (can be obtained from url using cacheKeyForURL) + * + * @return the default cache path + */ +- (NSString *)defaultCachePathForKey:(NSString *)key; + @end diff --git a/SDWebImage/SDImageCache.m b/SDWebImage/SDImageCache.m index 9ce82e21..0df9ad5f 100644 --- a/SDWebImage/SDImageCache.m +++ b/SDWebImage/SDImageCache.m @@ -116,8 +116,6 @@ BOOL ImageDataHasPNGPreffix(NSData *data) { } } -#pragma mark SDImageCache (private) - - (NSString *)cachePathForKey:(NSString *)key inPath:(NSString *)path { NSString *filename = [self cachedFileNameForKey:key]; return [path stringByAppendingPathComponent:filename]; @@ -127,6 +125,8 @@ BOOL ImageDataHasPNGPreffix(NSData *data) { return [self cachePathForKey:key inPath:self.diskCachePath]; } +#pragma mark SDImageCache (private) + - (NSString *)cachedFileNameForKey:(NSString *)key { const char *str = [key UTF8String]; if (str == NULL) {