ObjFW  Diff

Differences From Artifact [24716e0bdc]:

  • File utils/ofarc/LHAArchive.m — part of check-in [63caea2ec6] at 2025-04-16 00:07:52 on branch trunk — Finish migrating to the ARC functions for RR (user: js size: 14886) [more...]

To Artifact [7024a4aa9a]:

  • File utils/ofarc/LHAArchive.m — part of check-in [a99ff85e42] at 2025-06-14 22:49:05 on branch trunk — ofarc: Handle Ctrl-C on AmigaOS (user: js size: 15126)

135
136
137
138
139
140
141


142
143
144
145
146
147
148
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150







+
+








- (void)listFiles
{
	OFLHAArchiveEntry *entry;

	while ((entry = [_archive nextEntry]) != nil) {
		void *pool = objc_autoreleasePoolPush();

		[app checkForCancellation];

		[OFStdOut writeLine: entry.fileName];

		if (app->_outputLevel >= 1) {
			OFString *modificationDate = [entry.modificationDate
			    localDateStringWithFormat: @"%Y-%m-%d %H:%M:%S"];
			OFString *compressedSize = [OFString stringWithFormat:
283
284
285
286
287
288
289


290
291
292
293
294
295
296
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300







+
+







		void *pool = objc_autoreleasePoolPush();
		OFString *fileName = entry.fileName;
		OFString *outFileName, *directory;
		OFFile *output;
		OFStream *stream;
		unsigned long long written = 0, size = entry.uncompressedSize;
		int8_t percent = -1, newPercent;

		[app checkForCancellation];

		if (!all && ![files containsObject: fileName])
			continue;

		[missing removeObject: fileName];

		outFileName = [app safeLocalPathForPath: fileName];
342
343
344
345
346
347
348




349

350
351
352
353
354
355
356
346
347
348
349
350
351
352
353
354
355
356

357
358
359
360
361
362
363
364







+
+
+
+
-
+







			goto outer_loop_end;

		stream = [_archive streamForReadingCurrentEntry];
		output = [OFFile fileWithPath: outFileName mode: @"w"];
		setPermissions(outFileName, entry);

		while (!stream.atEndOfStream) {
			ssize_t length;

			[app checkForCancellation];

			ssize_t length = [app copyBlockFromStream: stream
			length = [app copyBlockFromStream: stream
							 toStream: output
							 fileName: fileName];

			if (length < 0) {
				app->_exitStatus = 1;
				goto outer_loop_end;
			}
417
418
419
420
421
422
423


424
425
426
427
428
429
430




431
432
433



434
435
436
437
438
439
440
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444



445
446
447
448
449
450
451
452
453
454







+
+







+
+
+
+
-
-
-
+
+
+







	}

	files = [OFMutableSet setWithArray: files_];

	while ((entry = [_archive nextEntry]) != nil) {
		OFString *fileName = entry.fileName;
		OFStream *stream;

		[app checkForCancellation];

		if (![files containsObject: fileName])
			continue;

		stream = [_archive streamForReadingCurrentEntry];

		while (!stream.atEndOfStream) {
			ssize_t length;

			[app checkForCancellation];

			ssize_t length = [app copyBlockFromStream: stream
							 toStream: OFStdOut
							 fileName: fileName];
			length = [app copyBlockFromStream: stream
						 toStream: OFStdOut
						 fileName: fileName];

			if (length < 0) {
				app->_exitStatus = 1;
				return;
			}
		}

460
461
462
463
464
465
466


467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489







+
+








	for (OFString *fileName in files) {
		void *pool = objc_autoreleasePoolPush();
		OFFileAttributes attributes;
		OFFileAttributeType type;
		OFMutableLHAArchiveEntry *entry;
		OFStream *output;

		[app checkForCancellation];

		if (app->_outputLevel >= 0)
			[OFStdErr writeString: OF_LOCALIZED(@"adding_file",
			    @"Adding %[file]...",
			    @"file", fileName)];

		attributes = [fileManager attributesOfItemAtPath: fileName];
506
507
508
509
510
511
512
513
514
515
516







517
518
519
520
521
522
523
522
523
524
525
526
527
528




529
530
531
532
533
534
535
536
537
538
539
540
541
542







-
-
-
-
+
+
+
+
+
+
+







			unsigned long long size = attributes.fileSize;
			int8_t percent = -1, newPercent;

			OFFile *input = [OFFile fileWithPath: fileName
							mode: @"r"];

			while (!input.atEndOfStream) {
				ssize_t length = [app
				    copyBlockFromStream: input
					       toStream: output
					       fileName: fileName];
				ssize_t length;

				[app checkForCancellation];

				length = [app copyBlockFromStream: input
							 toStream: output
							 fileName: fileName];

				if (length < 0) {
					app->_exitStatus = 1;
					goto outer_loop_end;
				}

				written += length;