52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
-
+
-
+
-
+
|
#endif
}
@implementation ZIPArchive
+ (void)initialize
{
if (self == [ZIPArchive class])
app = (OFZIP*)[[OFApplication sharedApplication] delegate];
app = (OFZIP *)[[OFApplication sharedApplication] delegate];
}
+ (instancetype)archiveWithStream: (OF_KINDOF(OFStream*))stream
+ (instancetype)archiveWithStream: (OF_KINDOF(OFStream *))stream
{
return [[[self alloc] initWithStream: stream] autorelease];
}
- initWithStream: (OF_KINDOF(OFStream*))stream
- initWithStream: (OF_KINDOF(OFStream *))stream
{
self = [super init];
@try {
_archive = [[OFZIPArchive alloc]
initWithSeekableStream: stream];
} @catch (id e) {
|
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
|
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
|
-
+
-
+
-
+
|
}
}
objc_autoreleasePoolPop(pool);
}
}
- (void)extractFiles: (OFArray OF_GENERIC(OFString*)*)files
- (void)extractFiles: (OFArray OF_GENERIC(OFString *) *)files
{
OFFileManager *fileManager = [OFFileManager defaultManager];
bool all = ([files count] == 0);
OFMutableSet OF_GENERIC(OFString*) *missing =
OFMutableSet OF_GENERIC(OFString *) *missing =
[OFMutableSet setWithArray: files];
for (OFZIPArchiveEntry *entry in [_archive entries]) {
void *pool = objc_autoreleasePoolPush();
OFString *fileName = [entry fileName];
OFString *outFileName = [fileName stringByStandardizingPath];
OFArray OF_GENERIC(OFString*) *pathComponents;
OFArray OF_GENERIC(OFString *) *pathComponents;
OFString *directory;
OFStream *stream;
OFFile *output;
uint64_t written = 0, size = [entry uncompressedSize];
int8_t percent = -1, newPercent;
if (!all && ![files containsObject: fileName])
|
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
|
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
|
-
+
|
@"File %[file] is not in the archive!",
@"file", file)];
app->_exitStatus = 1;
}
}
- (void)printFiles: (OFArray OF_GENERIC(OFString*)*)files
- (void)printFiles: (OFArray OF_GENERIC(OFString *) *)files
{
OFStream *stream;
if ([files count] < 1) {
[of_stderr writeLine: OF_LOCALIZED(@"print_no_file_specified",
@"Need one or more files to print!")];
app->_exitStatus = 1;
|