ObjFW  Diff

Differences From Artifact [6492307736]:

To Artifact [d383d3b508]:


250
251
252
253
254
255
256
257
258

259
260
261
262
263
264
265
266
267
268
269
250
251
252
253
254
255
256


257




258
259
260
261
262
263
264







-
-
+
-
-
-
-







	}

	return archive;
}

- (void)listFilesInArchive: (OFZIPArchive*)archive
{
	OFEnumerator OF_GENERIC(OFZIPArchiveEntry*) *enumerator;
	OFZIPArchiveEntry *entry;
	for (OFZIPArchiveEntry *entry in [archive entries]) {

	enumerator = [[archive entries] objectEnumerator];

	while ((entry = [enumerator nextObject]) != nil) {
		void *pool = objc_autoreleasePoolPush();

		[of_stdout writeLine: [entry fileName]];

		if (_outputLevel >= 1) {
			OFString *date = [[entry modificationDate]
			    localDateStringWithFormat: @"%Y-%m-%d %H:%M:%S"];
309
310
311
312
313
314
315
316
317
318
319


320
321
322

323
324

325
326
327
328
329
330
331

332
333
334
335
336
337
338
304
305
306
307
308
309
310




311
312



313
314

315

316
317
318
319


320
321
322
323
324
325
326
327







-
-
-
-
+
+
-
-
-
+

-
+
-




-
-
+







	}
}

- (void)extractFiles: (OFArray OF_GENERIC(OFString*)*)files
	 fromArchive: (OFZIPArchive*)archive
{
	OFFileManager *fileManager = [OFFileManager defaultManager];
	OFEnumerator OF_GENERIC(OFZIPArchiveEntry*) *entryEnumerator;
	OFZIPArchiveEntry *entry;
	bool all;
	OFMutableSet OF_GENERIC(OFString*) *missing;
	bool all = ([files count] == 0);
	OFMutableSet OF_GENERIC(OFString*) *missing =

	all = ([files count] == 0);
	missing = [OFMutableSet setWithArray: files];
	    [OFMutableSet setWithArray: files];

	entryEnumerator = [[archive entries] objectEnumerator];
	for (OFZIPArchiveEntry *entry in [archive entries]) {
	while ((entry = [entryEnumerator nextObject]) != nil) {
		void *pool = objc_autoreleasePoolPush();
		OFString *fileName = [entry fileName];
		OFString *outFileName = [fileName stringByStandardizingPath];
		OFArray OF_GENERIC(OFString*) *pathComponents;
		OFEnumerator OF_GENERIC(OFString*) *componentEnumerator;
		OFString *component, *directory;
		OFString *directory;
		OFStream *stream;
		OFFile *output;
		char buffer[BUFFER_SIZE];
		uint64_t written = 0, size = [entry uncompressedSize];
		int_fast8_t percent = -1, newPercent;

		if (!all && ![files containsObject: fileName])
350
351
352
353
354
355
356
357

358
359
360
361
362
363
364
365
339
340
341
342
343
344
345

346

347
348
349
350
351
352
353







-
+
-







						fileName];

			_exitStatus = 1;
			goto outer_loop_end;
		}

		pathComponents = [outFileName pathComponents];
		componentEnumerator = [pathComponents objectEnumerator];
		for (OFString *component in pathComponents) {
		while ((component = [componentEnumerator nextObject]) != nil) {
			if ([component isEqual: OF_PATH_PARENT_DIRECTORY]) {
				[of_stderr writeFormat:
				    @"Refusing to extract %@!\n", fileName];

				_exitStatus = 1;
				goto outer_loop_end;
			}
476
477
478
479
480
481
482
483
484

485
486
487
488
489
490
491
492
493
494
464
465
466
467
468
469
470


471



472
473
474
475
476
477
478







-
-
+
-
-
-







						fileName];

outer_loop_end:
		objc_autoreleasePoolPop(pool);
	}

	if ([missing count] > 0) {
		OFEnumerator OF_GENERIC(OFString*) *enumerator;
		OFString *file;
		for (OFString *file in missing)

		enumerator = [missing objectEnumerator];
		while ((file = [enumerator nextObject]) != nil)
			[of_stderr writeFormat:
			    @"File %@ is not in the archive!\n", file];

		_exitStatus = 1;
	}
}
@end