Index: src/OFLHAArchive.m ================================================================== --- src/OFLHAArchive.m +++ src/OFLHAArchive.m @@ -179,12 +179,13 @@ entry: (OFLHAArchiveEntry *)entry { self = [super init]; @try { - if ([entry method] != OF_LHA_ARCHIVE_ENTRY_METHOD_LH0 && - [entry method] != OF_LHA_ARCHIVE_ENTRY_METHOD_LHD) + OFString *method = [entry method]; + + if (![method isEqual: @"-lh0-"] && ![method isEqual: @"-lhd-"]) @throw [OFNotImplementedException exceptionWithSelector: _cmd object: self]; _entry = [entry copy]; Index: src/OFLHAArchiveEntry.h ================================================================== --- src/OFLHAArchiveEntry.h +++ src/OFLHAArchiveEntry.h @@ -21,32 +21,11 @@ @class OFArray OF_GENERIC(ObjectType); @class OFData; @class OFDate; @class OFNumber; - -/*! @file */ - -/*! - * @brief The compression method of the archive entry. - */ -typedef enum of_lha_archive_method_t { - /*! No compression */ - OF_LHA_ARCHIVE_ENTRY_METHOD_LH0, - OF_LHA_ARCHIVE_ENTRY_METHOD_LZS, - OF_LHA_ARCHIVE_ENTRY_METHOD_LZ4, - OF_LHA_ARCHIVE_ENTRY_METHOD_LH1, - OF_LHA_ARCHIVE_ENTRY_METHOD_LH2, - OF_LHA_ARCHIVE_ENTRY_METHOD_LH3, - OF_LHA_ARCHIVE_ENTRY_METHOD_LH4, - OF_LHA_ARCHIVE_ENTRY_METHOD_LH5, - OF_LHA_ARCHIVE_ENTRY_METHOD_LH6, - OF_LHA_ARCHIVE_ENTRY_METHOD_LH7, - OF_LHA_ARCHIVE_ENTRY_METHOD_LH8, - /*! Directory */ - OF_LHA_ARCHIVE_ENTRY_METHOD_LHD -} of_lha_archive_method_t; +@class OFString; /*! * @class OFLHAArchiveEntry OFLHAArchiveEntry.h ObjFW/OFLHAArchiveEntry.h * * @brief A class which represents an entry in the central directory of a LHA @@ -55,12 +34,11 @@ @interface OFLHAArchiveEntry: OFObject { #ifdef OF_LHA_ARCHIVE_ENTRY_M @public #endif - of_lha_archive_method_t _method; - OFString *_fileName, *_Nullable _directoryName; + OFString *_fileName, *_Nullable _directoryName, *_method; uint32_t _compressedSize, _uncompressedSize; OFDate *_date; uint8_t _level; uint16_t _CRC16; uint8_t _operatingSystemIdentifier; @@ -69,20 +47,20 @@ OFString *_Nullable _owner, *_Nullable _group; OFDate *_Nullable _modificationDate; OFArray OF_GENERIC(OFData *) *_extensions; } -/*! - * @brief The method of the entry. - */ -@property (readonly, nonatomic) of_lha_archive_method_t method; - /*! * @brief The file name of the entry. */ @property (readonly, copy, nonatomic) OFString *fileName; +/*! + * @brief The method of the entry. + */ +@property (readonly, copy, nonatomic) OFString *method; + /*! * @brief The compressed size of the entry's file. */ @property (readonly, nonatomic) uint32_t compressedSize; Index: src/OFLHAArchiveEntry.m ================================================================== --- src/OFLHAArchiveEntry.m +++ src/OFLHAArchiveEntry.m @@ -247,43 +247,14 @@ @throw [OFInvalidFormatException exception]; [stream readIntoBuffer: header exactLength: 20]; - if (memcmp(header + 1, "-lh0-", 5) == 0) - _method = OF_LHA_ARCHIVE_ENTRY_METHOD_LH0; - else if (memcmp(header + 1, "-lzs-", 5) == 0) - _method = OF_LHA_ARCHIVE_ENTRY_METHOD_LZS; - else if (memcmp(header + 1, "-lz4-", 5) == 0) - _method = OF_LHA_ARCHIVE_ENTRY_METHOD_LZ4; - else if (memcmp(header + 1, "-lh1-", 5) == 0) - _method = OF_LHA_ARCHIVE_ENTRY_METHOD_LH1; - else if (memcmp(header + 1, "-lh2-", 5) == 0) - _method = OF_LHA_ARCHIVE_ENTRY_METHOD_LH2; - else if (memcmp(header + 1, "-lh3-", 5) == 0) - _method = OF_LHA_ARCHIVE_ENTRY_METHOD_LH3; - else if (memcmp(header + 1, "-lh4-", 5) == 0) - _method = OF_LHA_ARCHIVE_ENTRY_METHOD_LH4; - else if (memcmp(header + 1, "-lh5-", 5) == 0) - _method = OF_LHA_ARCHIVE_ENTRY_METHOD_LH5; - else if (memcmp(header + 1, "-lh6-", 5) == 0) - _method = OF_LHA_ARCHIVE_ENTRY_METHOD_LH6; - else if (memcmp(header + 1, "-lh7-", 5) == 0) - _method = OF_LHA_ARCHIVE_ENTRY_METHOD_LH7; - else if (memcmp(header + 1, "-lh8-", 5) == 0) - _method = OF_LHA_ARCHIVE_ENTRY_METHOD_LH8; - else if (memcmp(header + 1, "-lhd-", 5) == 0) - _method = OF_LHA_ARCHIVE_ENTRY_METHOD_LHD; - else { - OFString *version = [OFString - stringWithCString: header + 1 - encoding: OF_STRING_ENCODING_ASCII - length: 5]; - - @throw [OFUnsupportedVersionException - exceptionWithVersion: version]; - } + _method = [[OFString alloc] + initWithCString: header + 1 + encoding: OF_STRING_ENCODING_ASCII + length: 5]; memcpy(&_compressedSize, header + 6, 4); _compressedSize = OF_BSWAP32_IF_BE(_compressedSize); memcpy(&_uncompressedSize, header + 10, 4); @@ -331,10 +302,11 @@ return self; } - (void)dealloc { + [_method release]; [_fileName release]; [_directoryName release]; [_date release]; [_fileComment release]; [_mode release]; @@ -370,10 +342,11 @@ stringByReplacingOccurrencesOfString: @"\n" withString: @"\n\t"]; OFString *ret = [OFString stringWithFormat: @"<%@:\n" @"\tFile name = %@\n" + @"\tMethod = %@\n" @"\tCompressed size = %" @PRIu32 "\n" @"\tUncompressed size = %" @PRIu32 "\n" @"\tDate = %@\n" @"\tLevel = %u\n" @"\tCRC16 = %04" @PRIX16 @"\n" @@ -385,16 +358,17 @@ @"\tOwner = %@\n" @"\tGroup = %@\n" @"\tModification date = %@\n" @"\tExtensions: %@" @">", - [self class], [self fileName], _compressedSize, _uncompressedSize, - _date, _level, _CRC16, _operatingSystemIdentifier, _fileComment, - mode, _UID, _GID, _owner, _group, _modificationDate, extensions]; + [self class], [self fileName], _method, _compressedSize, + _uncompressedSize, _date, _level, _CRC16, + _operatingSystemIdentifier, _fileComment, mode, _UID, _GID, _owner, + _group, _modificationDate, extensions]; [ret retain]; objc_autoreleasePoolPop(pool); return [ret autorelease]; } @end