-(void) getSize2
{
// picture cache
nsuinteger size = [sdimagecache sharedimagecache]. GetSize;
//NSLog (@ "%zd%@", Size, nstemporarydirectory ());
nsfilemanager *manager = [nsfilemanager defaultmanager];
// folder
nsstring *caches = [nssearchpathfordirectoriesindomains(nscachesdirectory, Nsuserdomainmask, YES) lastobject];
nsstring *cachepath = [caches stringbyappendingpathcomponent:@ "default/ Com.hackemist.SDWebImageCache.default "];
// get all contents inside the folder
//Nsarray *contents = [manager Contentsofdirectoryatpath:cachepath Error:nil];
nsarray *subpaths = [Manager Subpathsatpath: CachePath];
NSLog(@ "%@", subpaths);
}
-(void) GetSize
{
nsfilemanager *manager = [nsfilemanager defaultmanager];
nsstring *caches = [nssearchpathfordirectoriesindomains(nscachesdirectory, Nsuserdomainmask, YES) lastobject];
nsstring *cachepath = [caches stringbyappendingpathcomponent:@ "default/ Com.hackemist.SDWebImageCache.default "];
nsdirectoryenumerator *fileenumerator = [Manager Enumeratoratpath: CachePath];
nsinteger totalsize = 0;
for (nsstring *filename in fileenumerator) {
nsstring *filepath = [CachePath stringbyappendingpathcomponent: fileName];
BOOL dir = NO;
determine the type of file: File \ folder
[Manager Fileexistsatpath:filepath isdirectory:&dir];
if (dir) continue;
nsdictionary *attrs = [Manager attributesofitematpath: filepath error:nil];
if ([attrs[nsfiletype] isequaltostring:nsfiletypedirectory]) continue;
TotalSize + = [attrs[nsfilesize] integervalue];
}
NSLog(@ "%zd", totalsize);
}
iOS Compute Cache Size