-
Notifications
You must be signed in to change notification settings - Fork 0
/
BIQFileOperator.h
85 lines (70 loc) · 2.95 KB
/
BIQFileOperator.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
//
// FileOperator.h
//
// Created by Toma Popov on 1/23/15.
// Copyright (c) 2015. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface BIQFileOperator : NSObject
@property (nonatomic, readonly) NSOperationQueue *fileLoadQueue;
+ (instancetype)sharedInstance;
/*
In case the operaion is image lookup, the method first searches asynchronously
in the virtual image cache for an image with the specified url.
If not found, then searches in the defined local cache dir. A completion block is executed at the end.
*/
- (void)cachedDataForFileName:(NSString *)filename
isImageLookup:(BOOL)isImageLookup
completionQueue:(NSOperationQueue *)completionQueue
completion:(void (^)(NSData *result, NSError *error))completion;
/*
Converts the URL to filename and acts like previous API method(above)
*/
- (void)cachedDataForURL:(NSURL *)URL
isImageLookup:(BOOL)isImageLookup
completionQueue:(NSOperationQueue *)completionQueue
completion:(void (^)(NSData *result, NSError *error))completion;
/*
Caches asynchronously image files and adds them to a virtual image cache in case isImageOp is YES.
The cache gets cleaned when a memory warning is raised.
Completion block is passed at the end.
*/
- (void)storeData:(NSData *)data
isImageOp:(BOOL)isImageOp
fileName:(NSString *)filename
completionQueue:(NSOperationQueue *)completionQueue
completion:(void (^)(NSError *error))completion;
/*
Caches asynchronously image files and adds them to a virtual image cache in case isImageOp is YES.
The cache gets cleaned when a memory warning is raised.
Completion block is passed at the end.
*/
- (void)storeData:(NSData *)data
isImageOp:(BOOL)isImageOp
URL:(NSURL *)URL
completionQueue:(NSOperationQueue *)completionQueue
completion:(void (^)(NSError *error))completion;
/*
Deletes asynchronously specific files corresponding to core data entities. Completion block is passed at the end.
*/
- (void)removeCachedDataForEntities:(NSArray *)entities
ofClassType:(Class)classType
completionQueue:(NSOperationQueue *)completionQueue
completion:(void (^)(NSError *error))completion;
/*
Deletes asynchronously specific file. Completion block is passed at the end.
*/
- (void)removeCachedDataForFilename:(NSString *)filename
completionQueue:(NSOperationQueue *)completionQueue
completion:(void (^)(NSError *error))completion;
/*
Deletes asynchronously all cached files.
The manager itself has a private functinality that performs general clean up once every week.
*/
- (void)performAllFilesCleanUp;
//get a file path for specific file
- (NSString *)localFilePathForFilename:(NSString *)filename;
- (NSString *)localFilePathForURL:(NSURL *)url;
//add data to image cache
- (void)addDataToImageCache:(NSData *)data forFilename:(NSString *)filename;
@end