Differences From Artifact [1ef68b0ae3]:
- File src/OFLHAArchiveEntry.m — part of check-in [9f409b2ee0] at 2022-08-24 19:54:34 on branch trunk — OF*ArchiveEntry: Move inits to mutable class (user: js, size: 18335) [annotate] [blame] [check-ins using]
To Artifact [027838e133]:
- File
src/OFLHAArchiveEntry.m
— part of check-in
[327e67021e]
at
2022-08-25 19:56:25
on branch trunk
— OFLHAArchiveEntry: Merge date and modificationDate
The date is meant to be the modification date and the extension is
supposed to override the modification date on old LHA versions where the
modification date is only stored in local time. (user: js, size: 18018) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
310 311 312 313 314 315 316 | - (instancetype)of_init { self = [super init]; @try { _compressionMethod = @"-lh0-"; | | | 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 | - (instancetype)of_init { self = [super init]; @try { _compressionMethod = @"-lh0-"; _modificationDate = [[OFDate alloc] init]; } @catch (id e) { [self release]; @throw e; } return self; } |
︙ | ︙ | |||
352 353 354 355 356 357 358 | switch (_headerLevel) { case 0: case 1:; void *pool = objc_autoreleasePoolPush(); uint8_t fileNameLength; OFString *tmp; | | | | 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 | switch (_headerLevel) { case 0: case 1:; void *pool = objc_autoreleasePoolPush(); uint8_t fileNameLength; OFString *tmp; _modificationDate = [parseMSDOSDate(date) retain]; fileNameLength = [stream readInt8]; tmp = [stream readStringWithLength: fileNameLength encoding: encoding]; tmp = [tmp stringByReplacingOccurrencesOfString: @"\\" withString: @"/"]; _fileName = [tmp copy]; _CRC16 = [stream readLittleEndianInt16]; if (_headerLevel == 1) { _operatingSystemIdentifier = [stream readInt8]; readExtensions(self, stream, encoding, false); } objc_autoreleasePoolPop(pool); break; case 2: _modificationDate = [[OFDate alloc] initWithTimeIntervalSince1970: date]; _CRC16 = [stream readLittleEndianInt16]; _operatingSystemIdentifier = [stream readInt8]; readExtensions(self, stream, encoding, true); |
︙ | ︙ | |||
406 407 408 409 410 411 412 | } - (void)dealloc { [_compressionMethod release]; [_fileName release]; [_directoryName release]; | | | 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 | } - (void)dealloc { [_compressionMethod release]; [_fileName release]; [_directoryName release]; [_modificationDate release]; [_fileComment release]; [_mode release]; [_UID release]; [_GID release]; [_owner release]; [_group release]; [_extensions release]; |
︙ | ︙ | |||
432 433 434 435 436 437 438 | OFLHAArchiveEntry *copy = [[OFMutableLHAArchiveEntry alloc] initWithFileName: _fileName]; @try { [copy->_compressionMethod release]; copy->_compressionMethod = nil; | | | | < | 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 | OFLHAArchiveEntry *copy = [[OFMutableLHAArchiveEntry alloc] initWithFileName: _fileName]; @try { [copy->_compressionMethod release]; copy->_compressionMethod = nil; [copy->_modificationDate release]; copy->_modificationDate = nil; copy->_directoryName = [_directoryName copy]; copy->_compressionMethod = [_compressionMethod copy]; copy->_compressedSize = _compressedSize; copy->_uncompressedSize = _uncompressedSize; copy->_modificationDate = [_modificationDate copy]; copy->_headerLevel = _headerLevel; copy->_CRC16 = _CRC16; copy->_operatingSystemIdentifier = _operatingSystemIdentifier; copy->_fileComment = [_fileComment copy]; copy->_mode = [_mode retain]; copy->_UID = [_UID retain]; copy->_GID = [_GID retain]; copy->_owner = [_owner copy]; copy->_group = [_group copy]; copy->_extensions = [_extensions copy]; } @catch (id e) { [copy release]; @throw e; } return copy; |
︙ | ︙ | |||
482 483 484 485 486 487 488 | } - (uint32_t)uncompressedSize { return _uncompressedSize; } | | | | 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 | } - (uint32_t)uncompressedSize { return _uncompressedSize; } - (OFDate *)modificationDate { return _modificationDate; } - (uint8_t)headerLevel { return _headerLevel; } |
︙ | ︙ | |||
532 533 534 535 536 537 538 | } - (OFString *)group { return _group; } | < < < < < | 531 532 533 534 535 536 537 538 539 540 541 542 543 544 | } - (OFString *)group { return _group; } - (OFArray OF_GENERIC(OFData *) *)extensions { return _extensions; } - (void)of_writeToStream: (OFStream *)stream encoding: (OFStringEncoding)encoding |
︙ | ︙ | |||
577 578 579 580 581 582 583 | tmp32 = OFToLittleEndian32(_compressedSize); [data addItems: &tmp32 count: sizeof(tmp32)]; tmp32 = OFToLittleEndian32(_uncompressedSize); [data addItems: &tmp32 count: sizeof(tmp32)]; | | > | 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 | tmp32 = OFToLittleEndian32(_compressedSize); [data addItems: &tmp32 count: sizeof(tmp32)]; tmp32 = OFToLittleEndian32(_uncompressedSize); [data addItems: &tmp32 count: sizeof(tmp32)]; tmp32 = OFToLittleEndian32( (uint32_t)_modificationDate.timeIntervalSince1970); [data addItems: &tmp32 count: sizeof(tmp32)]; /* Reserved */ [data increaseCountBy: 1]; /* Header level */ [data addItem: "\x02"]; |
︙ | ︙ | |||
677 678 679 680 681 682 683 | tmp16 = OFToLittleEndian16((uint16_t)ownerLength + 3); [data addItems: &tmp16 count: sizeof(tmp16)]; [data addItem: "\x53"]; [data addItems: [_owner cStringWithEncoding: encoding] count: ownerLength]; } | < < < < < < < < < < | 672 673 674 675 676 677 678 679 680 681 682 683 684 685 | tmp16 = OFToLittleEndian16((uint16_t)ownerLength + 3); [data addItems: &tmp16 count: sizeof(tmp16)]; [data addItem: "\x53"]; [data addItems: [_owner cStringWithEncoding: encoding] count: ownerLength]; } for (OFData *extension in _extensions) { size_t extensionLength = extension.count; if (extension.itemSize != 1) @throw [OFInvalidArgumentException exception]; if (extensionLength > UINT16_MAX - 2) |
︙ | ︙ | |||
736 737 738 739 740 741 742 | withString: @"\n\t"]; OFString *ret = [OFString stringWithFormat: @"<%@:\n" @"\tFile name = %@\n" @"\tCompression method = %@\n" @"\tCompressed size = %" @PRIu32 "\n" @"\tUncompressed size = %" @PRIu32 "\n" | | < | | | 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 | withString: @"\n\t"]; OFString *ret = [OFString stringWithFormat: @"<%@:\n" @"\tFile name = %@\n" @"\tCompression method = %@\n" @"\tCompressed size = %" @PRIu32 "\n" @"\tUncompressed size = %" @PRIu32 "\n" @"\tModification date = %@\n" @"\tHeader level = %u\n" @"\tCRC16 = %04" @PRIX16 @"\n" @"\tOperating system identifier = %c\n" @"\tComment = %@\n" @"\tMode = %@\n" @"\tUID = %@\n" @"\tGID = %@\n" @"\tOwner = %@\n" @"\tGroup = %@\n" @"\tExtensions: %@" @">", self.class, self.fileName, _compressionMethod, _compressedSize, _uncompressedSize, _modificationDate, _headerLevel, _CRC16, _operatingSystemIdentifier, _fileComment, mode, _UID, _GID, _owner, _group, extensions]; [ret retain]; objc_autoreleasePoolPop(pool); return [ret autorelease]; } @end |