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
|
/*
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
* Alternatively, it may be distributed under the terms of the GNU General
* Public License, either version 2 or 3, which can be found in the file
* LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
* file.
*/
#include "config.h"
#include <errno.h>
#import "OFApplication.h"
#import "OFData.h"
#import "OFDate.h"
#import "OFFileManager.h"
#import "OFLocale.h"
#import "OFNumber.h"
#import "OFSet.h"
#import "OFStdIOStream.h"
#import "OFString.h"
#import "ZIPArchive.h"
#import "OFArc.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
|
/*
* Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
* Alternatively, it may be distributed under the terms of the GNU General
* Public License, either version 2 or 3, which can be found in the file
* LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
* file.
*/
#include "config.h"
#include <errno.h>
#import "OFApplication.h"
#import "OFArray.h"
#import "OFData.h"
#import "OFDate.h"
#import "OFFileManager.h"
#import "OFLocale.h"
#import "OFNumber.h"
#import "OFPair.h"
#import "OFSet.h"
#import "OFStdIOStream.h"
#import "OFString.h"
#import "ZIPArchive.h"
#import "OFArc.h"
|
︙ | | | ︙ | |
269
270
271
272
273
274
275
276
277
278
279
280
281
282
|
}
}
- (void)extractFiles: (OFArray OF_GENERIC(OFString *) *)files
{
OFFileManager *fileManager = [OFFileManager defaultManager];
bool all = (files.count == 0);
OFMutableSet OF_GENERIC(OFString *) *missing =
[OFMutableSet setWithArray: files];
for (OFZIPArchiveEntry *entry in _archive.entries) {
void *pool = objc_autoreleasePoolPush();
OFString *fileName = entry.fileName;
OFString *outFileName, *directory;
|
>
|
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
|
}
}
- (void)extractFiles: (OFArray OF_GENERIC(OFString *) *)files
{
OFFileManager *fileManager = [OFFileManager defaultManager];
bool all = (files.count == 0);
OFMutableArray *delayedModificationDates = [OFMutableArray array];
OFMutableSet OF_GENERIC(OFString *) *missing =
[OFMutableSet setWithArray: files];
for (OFZIPArchiveEntry *entry in _archive.entries) {
void *pool = objc_autoreleasePoolPush();
OFString *fileName = entry.fileName;
OFString *outFileName, *directory;
|
︙ | | | ︙ | |
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
|
@"Extracting %[file]...",
@"file", fileName)];
if ([fileName hasSuffix: @"/"]) {
[fileManager createDirectoryAtPath: outFileName
createParents: true];
setPermissions(outFileName, entry);
setModificationDate(outFileName, entry);
if (app->_outputLevel >= 0) {
[OFStdOut writeString: @"\r"];
[OFStdOut writeLine: OF_LOCALIZED(
@"extracting_file_done",
@"Extracting %[file]... done",
@"file", fileName)];
|
>
>
>
>
>
|
>
>
|
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
|
@"Extracting %[file]...",
@"file", fileName)];
if ([fileName hasSuffix: @"/"]) {
[fileManager createDirectoryAtPath: outFileName
createParents: true];
setPermissions(outFileName, entry);
/*
* As creating a new file in a directory changes its
* modification date, we can only set it once all files
* have been created.
*/
[delayedModificationDates addObject:
[OFPair pairWithFirstObject: outFileName
secondObject: entry]];
if (app->_outputLevel >= 0) {
[OFStdOut writeString: @"\r"];
[OFStdOut writeLine: OF_LOCALIZED(
@"extracting_file_done",
@"Extracting %[file]... done",
@"file", fileName)];
|
︙ | | | ︙ | |
376
377
378
379
380
381
382
383
384
385
386
387
388
389
|
@"file", fileName)];
}
outer_loop_end:
objc_autoreleasePoolPop(pool);
}
if (missing.count > 0) {
for (OFString *file in missing)
[OFStdErr writeLine: OF_LOCALIZED(
@"file_not_in_archive",
@"File %[file] is not in the archive!",
@"file", file)];
|
>
>
>
|
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
|
@"file", fileName)];
}
outer_loop_end:
objc_autoreleasePoolPop(pool);
}
for (OFPair *pair in delayedModificationDates)
setModificationDate(pair.firstObject, pair.secondObject);
if (missing.count > 0) {
for (OFString *file in missing)
[OFStdErr writeLine: OF_LOCALIZED(
@"file_not_in_archive",
@"File %[file] is not in the archive!",
@"file", file)];
|
︙ | | | ︙ | |