File tree Expand file tree Collapse file tree 2 files changed +32
-0
lines changed Expand file tree Collapse file tree 2 files changed +32
-0
lines changed Original file line number Diff line number Diff line change 3535 */  
3636+ (NSString  *)defaultCachePath ;
3737
38+ /* 
39+  * Checks if the provided URL exists in cache. 
40+  */  
41+ - (BOOL )isCached : (NSURL  *)url ;
42+ 
43+ /* 
44+  * Removes the cache contents. 
45+  */  
46+ - (BOOL )clearCache ;
47+ 
3848@end 
Original file line number Diff line number Diff line change @@ -503,6 +503,28 @@ - (void)removeAllCachedResponses
503503 [super  removeAllCachedResponses ];
504504}
505505
506+ - (BOOL )clearCache 
507+ {
508+  NSFileManager  *fileManager = [[[NSFileManager  alloc ] init ] autorelease ];
509+  return  [fileManager removeItemAtPath: diskCachePath error: NULL ];
510+ }
511+ 
512+ - (BOOL )isCached : (NSURL  *)url 
513+ {
514+  NSURLRequest  *request = [NSURLRequest  requestWithURL: url];
515+  if  ([super  cachedResponseForRequest: request])
516+  {
517+  return  YES ;
518+  }
519+  NSString  *cacheKey = [SDURLCache cacheKeyForURL: url];
520+  NSString  *cacheFile = [diskCachePath stringByAppendingPathComponent: cacheKey];
521+  if  ([[[[NSFileManager  alloc ] init ] autorelease ] fileExistsAtPath: cacheFile])
522+  {
523+  return  YES ;
524+  }
525+  return  NO ;
526+ }
527+ 
506528#pragma mark  NSObject
507529
508530- (void )dealloc 
                         You can’t perform that action at this time. 
           
                  
0 commit comments