diff --git a/Tests/Tests/SDWebImageTestCache.m b/Tests/Tests/SDWebImageTestCache.m index 7ef29cf7..68b2a154 100644 --- a/Tests/Tests/SDWebImageTestCache.m +++ b/Tests/Tests/SDWebImageTestCache.m @@ -9,6 +9,9 @@ #import "SDWebImageTestCache.h" #import +#import "SDFileAttributeHelper.h" + +static NSString * const SDWebImageTestDiskCacheExtendedAttributeName = @"com.hackemist.SDWebImageTestDiskCache"; @implementation SDWebImageTestMemoryCache @@ -104,4 +107,18 @@ return size; } +- (nullable NSData *)extendedDataForKey:(nonnull NSString *)key { + NSString *cachePathForKey = [self cachePathForKey:key]; + return [SDFileAttributeHelper extendedAttribute:SDWebImageTestDiskCacheExtendedAttributeName atPath:cachePathForKey traverseLink:NO error:nil]; +} + +- (void)setExtendedData:(nullable NSData *)extendedData forKey:(nonnull NSString *)key { + NSString *cachePathForKey = [self cachePathForKey:key]; + if (!extendedData) { + [SDFileAttributeHelper removeExtendedAttribute:SDWebImageTestDiskCacheExtendedAttributeName atPath:cachePathForKey traverseLink:NO error:nil]; + } else { + [SDFileAttributeHelper setExtendedAttribute:SDWebImageTestDiskCacheExtendedAttributeName value:extendedData atPath:cachePathForKey traverseLink:NO overwrite:YES error:nil]; + } +} + @end