Overview
Comment: | ofzip: Support for creating / appending tar files |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
ddfb995c90749d7b1e5d19e856d34b8f |
User & Date: | js on 2017-08-05 21:39:59 |
Other Links: | manifest | tags |
Context
2017-08-05
| ||
21:43 | make tarball: Use ofzip to create tarball check-in: a0b3632d8a user: js tags: trunk | |
21:39 | ofzip: Support for creating / appending tar files check-in: ddfb995c90 user: js tags: trunk | |
21:14 | OFMutableTarArchiveEntry: Fix typo check-in: d755a2d6ca user: js tags: trunk | |
Changes
Modified src/OFTarArchive.m from [cb4c96888d] to [4feff55415].
︙ | ︙ | |||
291 292 293 294 295 296 297 298 299 300 301 302 303 304 | objc_autoreleasePoolPop(pool); return [[_lastReturnedStream retain] autorelease]; } - (void)close { [_lastReturnedStream close]; [_lastReturnedStream release]; _lastReturnedStream = nil; if (_mode == OF_TAR_ARCHIVE_MODE_WRITE || _mode == OF_TAR_ARCHIVE_MODE_APPEND) { char buffer[1024]; | > > > | 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 | objc_autoreleasePoolPop(pool); return [[_lastReturnedStream retain] autorelease]; } - (void)close { if (_stream == nil) return; [_lastReturnedStream close]; [_lastReturnedStream release]; _lastReturnedStream = nil; if (_mode == OF_TAR_ARCHIVE_MODE_WRITE || _mode == OF_TAR_ARCHIVE_MODE_APPEND) { char buffer[1024]; |
︙ | ︙ | |||
473 474 475 476 477 478 479 480 481 482 483 484 485 486 | - (int)fileDescriptorForWriting { return [_stream fileDescriptorForWriting]; } - (void)close { uint64_t remainder = 512 - [_entry size] % 512; if (_toWrite > 0) @throw [OFTruncatedDataException exception]; if (remainder != 512) { bool wasWriteBuffered = [_stream isWriteBuffered]; | > > > | 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 | - (int)fileDescriptorForWriting { return [_stream fileDescriptorForWriting]; } - (void)close { if (_stream == nil) return; uint64_t remainder = 512 - [_entry size] % 512; if (_toWrite > 0) @throw [OFTruncatedDataException exception]; if (remainder != 512) { bool wasWriteBuffered = [_stream isWriteBuffered]; |
︙ | ︙ |
Modified utils/ofzip/OFZIP.m from [a1e700c9d6] to [3ce56a9b94].
︙ | ︙ | |||
272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 | mode: mode]; if (outputDir != nil) [[OFFileManager defaultManager] changeCurrentDirectoryPath: outputDir]; switch (mode) { case 'l': if ([remainingArguments count] != 1) help(of_stderr, false, 1); [archive listFiles]; break; case 'x': if ([remainingArguments count] < 1) help(of_stderr, false, 1); files = [remainingArguments objectsInRange: of_range(1, [remainingArguments count] - 1)]; | > > > > > > > > > > > > > > > > > > > | 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 | mode: mode]; if (outputDir != nil) [[OFFileManager defaultManager] changeCurrentDirectoryPath: outputDir]; switch (mode) { case 'a': case 'c': if ([remainingArguments count] < 1) help(of_stderr, false, 1); files = [remainingArguments objectsInRange: of_range(1, [remainingArguments count] - 1)]; [archive addFiles: files]; break; case 'l': if ([remainingArguments count] != 1) help(of_stderr, false, 1); [archive listFiles]; break; case 'p': if ([remainingArguments count] < 1) help(of_stderr, false, 1); files = [remainingArguments objectsInRange: of_range(1, [remainingArguments count] - 1)]; [archive printFiles: files]; break; case 'x': if ([remainingArguments count] < 1) help(of_stderr, false, 1); files = [remainingArguments objectsInRange: of_range(1, [remainingArguments count] - 1)]; |
︙ | ︙ | |||
312 313 314 315 316 317 318 | @"Failed to open file %[file]: %[error]", @"file", [e path], @"error", error)]; _exitStatus = 1; } break; | < < < < < < < < < | 331 332 333 334 335 336 337 338 339 340 341 342 343 344 | @"Failed to open file %[file]: %[error]", @"file", [e path], @"error", error)]; _exitStatus = 1; } break; default: help(of_stderr, true, 1); break; } [OFApplication terminateWithStatus: _exitStatus]; } |
︙ | ︙ |
Modified utils/ofzip/TarArchive.m from [50de2565fd] to [4669023b91].
︙ | ︙ | |||
422 423 424 425 426 427 428 429 | for (OFString *file in files) { [of_stderr writeLine: OF_LOCALIZED(@"file_not_in_archive", @"File %[file] is not in the archive!", @"file", file)]; app->_exitStatus = 1; } } @end | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 422 423 424 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 455 456 457 458 459 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 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 | for (OFString *file in files) { [of_stderr writeLine: OF_LOCALIZED(@"file_not_in_archive", @"File %[file] is not in the archive!", @"file", file)]; app->_exitStatus = 1; } } - (void)addFiles: (OFArray OF_GENERIC(OFString *) *)files { OFFileManager *fileManager = [OFFileManager defaultManager]; if ([files count] < 1) { [of_stderr writeLine: OF_LOCALIZED(@"add_no_file_specified", @"Need one or more files to add!")]; app->_exitStatus = 1; return; } for (OFString *fileName in files) { void *pool = objc_autoreleasePoolPush(); OFMutableTarArchiveEntry *entry; OFStream *output; if (app->_outputLevel >= 0) [of_stdout writeString: OF_LOCALIZED(@"adding_file", @"Adding %[file]...", @"file", fileName)]; entry = [OFMutableTarArchiveEntry entryWithFileName: fileName]; #ifdef OF_FILE_MANAGER_SUPPORTS_PERMISSIONS [entry setMode: [fileManager permissionsOfItemAtPath: fileName]]; #endif [entry setSize: [fileManager sizeOfFileAtPath: fileName]]; [entry setModificationDate: [fileManager modificationTimeOfItemAtPath: fileName]]; #ifdef OF_FILE_MANAGER_SUPPORTS_OWNER OFString *owner, *group; [fileManager getOwner: &owner group: &group ofItemAtPath: fileName]; [entry setOwner: owner]; [entry setGroup: group]; #endif if ([fileManager fileExistsAtPath: fileName]) [entry setType: OF_TAR_ARCHIVE_ENTRY_TYPE_FILE]; else if ([fileManager directoryExistsAtPath: fileName]) { [entry setType: OF_TAR_ARCHIVE_ENTRY_TYPE_DIRECTORY]; [entry setSize: 0]; } else if ([fileManager symbolicLinkExistsAtPath: fileName]) { [entry setType: OF_TAR_ARCHIVE_ENTRY_TYPE_SYMLINK]; [entry setTargetFileName: [fileManager destinationOfSymbolicLinkAtPath: fileName]]; [entry setSize: 0]; } [entry makeImmutable]; output = [_archive streamForWritingEntry: entry]; if ([entry type] == OF_TAR_ARCHIVE_ENTRY_TYPE_FILE) { uint64_t written = 0, size = [entry size]; int8_t percent = -1, newPercent; OFFile *input = [OFFile fileWithPath: fileName mode: @"r"]; while (![input isAtEndOfStream]) { ssize_t length = [app copyBlockFromStream: input toStream: output fileName: fileName]; if (length < 0) { app->_exitStatus = 1; goto outer_loop_end; } written += length; newPercent = (written == size ? 100 : (int8_t)(written * 100 / size)); if (app->_outputLevel >= 0 && percent != newPercent) { OFString *percentString; percent = newPercent; percentString = [OFString stringWithFormat: @"%3u", percent]; [of_stdout writeString: @"\r"]; [of_stdout writeString: OF_LOCALIZED( @"adding_file_percent", @"Adding %[file]... %[percent]%", @"file", fileName, @"percent", percentString)]; } } } if (app->_outputLevel >= 0) { [of_stdout writeString: @"\r"]; [of_stdout writeLine: OF_LOCALIZED( @"adding_file_done", @"Adding %[file]... done", @"file", fileName)]; } [output close]; outer_loop_end: objc_autoreleasePoolPop(pool); } [_archive close]; } @end |
Modified utils/ofzip/lang/de.json from [e0aac008e1] to [3ac6a038db].
︙ | ︙ | |||
86 87 88 89 90 91 92 | "list_general_purpose_bit_flag": "General Purpose Bit Flag: %[gpbf]", "list_extra_field": "Extra-Feld: %[extra]", "list_comment": "Kommentar: %[comment]", "refusing_to_extract_file": "Verweigere Entpacken von %[file]!", "file_not_in_archive": "Datei %[file] ist nicht im Archiv!", "print_no_file_specified": [ "Benötige eine oder mehrere Dateien zum Ausgeben!" | | > > > > > > | 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 | "list_general_purpose_bit_flag": "General Purpose Bit Flag: %[gpbf]", "list_extra_field": "Extra-Feld: %[extra]", "list_comment": "Kommentar: %[comment]", "refusing_to_extract_file": "Verweigere Entpacken von %[file]!", "file_not_in_archive": "Datei %[file] ist nicht im Archiv!", "print_no_file_specified": [ "Benötige eine oder mehrere Dateien zum Ausgeben!" ], "add_no_file_specified": [ "Benötige eine oder mehrere Dateien zum Hinzufügen!" ], "adding_file": "Füge %[file] hinzu...", "adding_file_percent": "Füge %[file] hinzu... %[percent]%", "adding_file_done": "Füge %[file] hinzu... fertig" } |