-
Notifications
You must be signed in to change notification settings - Fork 99
/
TWRDownloadManager.h
97 lines (77 loc) · 4.03 KB
/
TWRDownloadManager.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
86
87
88
89
90
91
92
93
94
95
96
97
//
// TWRDownloadManager.h
// DownloadManager
//
// Created by Michelangelo Chasseur on 25/07/14.
// Copyright (c) 2014 Touchware. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <CoreGraphics/CGBase.h>
@interface TWRDownloadManager : NSObject
@property (nonatomic, strong) void(^backgroundTransferCompletionHandler)();
+ (instancetype)sharedManager;
- (void)downloadFileForURL:(NSString *)urlString
withName:(NSString *)fileName
inDirectoryNamed:(NSString *)directory
friendlyName:(NSString *)friendlyName
progressBlock:(void(^)(CGFloat progress))progressBlock
remainingTime:(void(^)(NSUInteger seconds))remainingTimeBlock
completionBlock:(void(^)(BOOL completed))completionBlock
enableBackgroundMode:(BOOL)backgroundMode;
- (void)downloadFileForURL:(NSString *)url
withName:(NSString *)fileName
inDirectoryNamed:(NSString *)directory
progressBlock:(void(^)(CGFloat progress))progressBlock
completionBlock:(void(^)(BOOL completed))completionBlock
enableBackgroundMode:(BOOL)backgroundMode;
- (void)downloadFileForURL:(NSString *)url
inDirectoryNamed:(NSString *)directory
progressBlock:(void(^)(CGFloat progress))progressBlock
completionBlock:(void(^)(BOOL completed))completionBlock
enableBackgroundMode:(BOOL)backgroundMode;
- (void)downloadFileForURL:(NSString *)url
progressBlock:(void(^)(CGFloat progress))progressBlock
completionBlock:(void(^)(BOOL completed))completionBlock
enableBackgroundMode:(BOOL)backgroundMode;
#pragma mark - Download with estimated time
- (void)downloadFileForURL:(NSString *)url
withName:(NSString *)fileName
inDirectoryNamed:(NSString *)directory
progressBlock:(void(^)(CGFloat progress))progressBlock
remainingTime:(void(^)(NSUInteger seconds))remainingTimeBlock
completionBlock:(void(^)(BOOL completed))completionBlock
enableBackgroundMode:(BOOL)backgroundMode;
- (void)downloadFileForURL:(NSString *)url
inDirectoryNamed:(NSString *)directory
progressBlock:(void(^)(CGFloat progress))progressBlock
remainingTime:(void(^)(NSUInteger seconds))remainingTimeBlock
completionBlock:(void(^)(BOOL completed))completionBlock
enableBackgroundMode:(BOOL)backgroundMode;
- (void)downloadFileForURL:(NSString *)url
progressBlock:(void(^)(CGFloat progress))progressBlock
remainingTime:(void(^)(NSUInteger seconds))remainingTimeBlock
completionBlock:(void(^)(BOOL completed))completionBlock
enableBackgroundMode:(BOOL)backgroundMode;
- (void)cancelAllDownloads;
- (void)cancelDownloadForUrl:(NSString *)fileIdentifier;
- (void)cleanDirectoryNamed:(NSString *)directory;
- (BOOL)isFileDownloadingForUrl:(NSString *)fileIdentifier;
- (BOOL)isFileDownloadingForUrl:(NSString *)url withProgressBlock:(void(^)(CGFloat progress))block;
- (BOOL)isFileDownloadingForUrl:(NSString *)url withProgressBlock:(void(^)(CGFloat progress))block completionBlock:(void(^)(BOOL completed))completionBlock;
- (NSString *)localPathForFile:(NSString *)fileIdentifier;
- (NSString *)localPathForFile:(NSString *)fileIdentifier inDirectory:(NSString *)directoryName;
- (BOOL)fileExistsForUrl:(NSString *)urlString;
- (BOOL)fileExistsForUrl:(NSString *)urlString inDirectory:(NSString *)directoryName;
- (BOOL)fileExistsWithName:(NSString *)fileName;
- (BOOL)fileExistsWithName:(NSString *)fileName inDirectory:(NSString *)directoryName;
- (BOOL)deleteFileForUrl:(NSString *)urlString;
- (BOOL)deleteFileForUrl:(NSString *)urlString inDirectory:(NSString *)directoryName;
- (BOOL)deleteFileWithName:(NSString *)fileName;
- (BOOL)deleteFileWithName:(NSString *)fileName inDirectory:(NSString *)directoryName;
/**
* This method helps checking which downloads are currently ongoing.
*
* @return an NSArray of NSString with the URLs of the currently downloading files.
*/
- (NSArray *)currentDownloads;
@end