︙ | | | ︙ | |
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
static void
mutuallyExclusiveError(of_unichar_t option1, of_unichar_t option2)
{
[of_stderr writeFormat: @"Error: -%C and -%C are mutually exclusive!\n",
option1, option2];
[OFApplication terminateWithStatus: 1];
}
@implementation OFZIP
- (void)applicationDidFinishLaunching
{
OFOptionsParser *optionsParser =
[OFOptionsParser parserWithOptions: @"fhlnqvx"];
of_unichar_t option, mode = '\0';
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
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
104
|
static void
mutuallyExclusiveError(of_unichar_t option1, of_unichar_t option2)
{
[of_stderr writeFormat: @"Error: -%C and -%C are mutually exclusive!\n",
option1, option2];
[OFApplication terminateWithStatus: 1];
}
static void
setPermissions(OFString *path, OFZIPArchiveEntry *entry)
{
#ifdef OF_HAVE_CHMOD
if (([entry versionMadeBy] >> 8) ==
OF_ZIP_ARCHIVE_ENTRY_ATTR_COMPAT_UNIX) {
uint32_t mode = [entry versionSpecificAttributes] >> 16;
/* Only allow modes that are safe */
mode &= (S_IRWXU | S_IRWXG | S_IRWXO);
[OFFile changePermissionsOfItemAtPath: path
permissions: mode];
}
#endif
}
@implementation OFZIP
- (void)applicationDidFinishLaunching
{
OFOptionsParser *optionsParser =
[OFOptionsParser parserWithOptions: @"fhlnqvx"];
of_unichar_t option, mode = '\0';
|
︙ | | | ︙ | |
210
211
212
213
214
215
216
217
218
219
220
221
222
223
|
localDateStringWithFormat: @"%Y-%m-%d %H:%M:%S"];
[of_stdout writeFormat:
@"%@: %" PRIu64 @" (%" PRIu64 @") bytes; %08X; %@; "
@"%@", [entry fileName], [entry uncompressedSize],
[entry compressedSize], [entry CRC32], date,
[entry fileComment]];
if (_outputLevel >= 3)
[of_stdout writeFormat: @"; %@",
[entry extraField]];
[of_stdout writeString: @"\n"];
} else
|
>
>
>
>
>
>
>
>
>
>
|
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
|
localDateStringWithFormat: @"%Y-%m-%d %H:%M:%S"];
[of_stdout writeFormat:
@"%@: %" PRIu64 @" (%" PRIu64 @") bytes; %08X; %@; "
@"%@", [entry fileName], [entry uncompressedSize],
[entry compressedSize], [entry CRC32], date,
[entry fileComment]];
if (_outputLevel >= 2) {
if (([entry versionMadeBy] >> 8) ==
OF_ZIP_ARCHIVE_ENTRY_ATTR_COMPAT_UNIX) {
uint32_t mode = [entry
versionSpecificAttributes] >> 16;
[of_stdout writeFormat: @"; %06o",
mode];
}
}
if (_outputLevel >= 3)
[of_stdout writeFormat: @"; %@",
[entry extraField]];
[of_stdout writeString: @"\n"];
} else
|
︙ | | | ︙ | |
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
|
if (_outputLevel >= 0)
[of_stdout writeFormat: @"Extracting %@...", fileName];
if ([fileName hasSuffix: @"/"]) {
[OFFile createDirectoryAtPath: outFileName
createParents: true];
if (_outputLevel >= 0)
[of_stdout writeLine: @" done"];
continue;
}
directory = [outFileName stringByDeletingLastPathComponent];
if (![OFFile directoryExistsAtPath: directory])
[OFFile createDirectoryAtPath: directory
createParents: true];
|
>
>
>
|
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
|
if (_outputLevel >= 0)
[of_stdout writeFormat: @"Extracting %@...", fileName];
if ([fileName hasSuffix: @"/"]) {
[OFFile createDirectoryAtPath: outFileName
createParents: true];
setPermissions(outFileName, entry);
if (_outputLevel >= 0)
[of_stdout writeLine: @" done"];
continue;
}
directory = [outFileName stringByDeletingLastPathComponent];
if (![OFFile directoryExistsAtPath: directory])
[OFFile createDirectoryAtPath: directory
createParents: true];
|
︙ | | | ︙ | |
328
329
330
331
332
333
334
335
336
337
338
339
340
341
|
[of_stdout writeFormat: @"Extracting %@...", fileName];
}
stream = [archive streamForReadingFile: fileName];
output = [OFFile fileWithPath: outFileName
mode: @"wb"];
while (![stream isAtEndOfStream]) {
size_t length = [stream readIntoBuffer: buffer
length: BUFFER_SIZE];
[output writeBuffer: buffer
length: length];
|
>
|
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
|
[of_stdout writeFormat: @"Extracting %@...", fileName];
}
stream = [archive streamForReadingFile: fileName];
output = [OFFile fileWithPath: outFileName
mode: @"wb"];
setPermissions(outFileName, entry);
while (![stream isAtEndOfStream]) {
size_t length = [stream readIntoBuffer: buffer
length: BUFFER_SIZE];
[output writeBuffer: buffer
length: length];
|
︙ | | | ︙ | |