forked from rob-brown/RBFilePreviewer
-
Notifications
You must be signed in to change notification settings - Fork 1
/
RBFile.h
103 lines (89 loc) · 3.28 KB
/
RBFile.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
98
99
100
101
102
103
//
// RBFile.h
//
// Copyright (c) 2011 Robert Brown
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//
#import <Foundation/Foundation.h>
#import <QuickLook/QuickLook.h>
#import "RBFileGenerator.h"
/**
* Represents a file created from RBFileGenerator or an existing file. If a
* file is set up for lazy loading, you should be careful about caching the
* file's NSURL. File unloading can be turned off by setting canUnload to NO.
*/
@interface RBFile : NSObject <QLPreviewItem>
/**
* An optional ivar for holding a file generator for lazy loading files.
*/
@property (nonatomic, retain) id<RBFileGenerator> fileGenerator;
/**
* An optional title to give to the file. If no title is given, then the title
* defaults to the file name.
*/
@property (nonatomic, copy) NSString * title;
/**
* The MIME type of the file. A MIME type may either be specified or inferred
* from a file generator or the file extension, in that order.
*/
@property (nonatomic, copy) NSString * MIMEType;
/**
* When set to NO, prevents the file from being unloaded. If you want to
* guarantee that a file will be loaded, set this property to NO before
* requesting the file's URL. Default value is NO.
*/
@property (nonatomic, assign) BOOL canUnload;
/**
* Creates the file from the given file generator. The underlying file isn't
* created right away. It is lazy loaded when it is accessed through the
* QLPreviewItem protocol. This can be beneficial when you don't want to
* generate large files when you don't need to.
*
* @param generator The file generator to use to create the underlying file.
*/
- (id) initWithFileGenerator:(id<RBFileGenerator>)generator;
/**
* Creates the file from the given URL.
*
* @param fileURL The URL that points to the file.
*/
- (id) initWithURL:(NSURL *)fileURL;
/**
* Forces the file to be generated if it isn't already.
*/
- (void) generateFile;
/**
* Deletes the underlying file if a file generator can reload it later.
*/
- (void) unloadFile;
/**
* Returns YES if the file exists.
*
* @return YES if the file exists.
*/
- (BOOL) isFileLoaded;
/**
* Convenience method. Simply returns the file's URL. Simply calls
* -previewItemURL. This name change makes more sense in general use.
*
* @return The file's URL.
*/
- (NSURL *)fileURL;
@end