@@ -111,70 +111,73 @@ static void parsePermissionsExtension(OFLHAArchiveEntry *entry, OFData *extension, OFStringEncoding encoding) { - uint16_t mode; + uint16_t POSIXPermissions; if (extension.count != 3) @throw [OFInvalidFormatException exception]; - memcpy(&mode, (char *)extension.items + 1, 2); - mode = OFFromLittleEndian16(mode); + memcpy(&POSIXPermissions, (char *)extension.items + 1, 2); + POSIXPermissions = OFFromLittleEndian16(POSIXPermissions); - [entry->_mode release]; - entry->_mode = nil; + [entry->_POSIXPermissions release]; + entry->_POSIXPermissions = nil; - entry->_mode = [[OFNumber alloc] initWithUnsignedShort: mode]; + entry->_POSIXPermissions = + [[OFNumber alloc] initWithUnsignedShort: POSIXPermissions]; } static void parseGIDUIDExtension(OFLHAArchiveEntry *entry, OFData *extension, OFStringEncoding encoding) { - uint16_t UID, GID; + uint16_t ownerAccountID, groupOwnerAccountID; if (extension.count != 5) @throw [OFInvalidFormatException exception]; - memcpy(&GID, (char *)extension.items + 1, 2); - GID = OFFromLittleEndian16(GID); - - memcpy(&UID, (char *)extension.items + 3, 2); - UID = OFFromLittleEndian16(UID); - - [entry->_GID release]; - entry->_GID = nil; - - [entry->_UID release]; - entry->_UID = nil; - - entry->_GID = [[OFNumber alloc] initWithUnsignedShort: GID]; - entry->_UID = [[OFNumber alloc] initWithUnsignedShort: UID]; + memcpy(&groupOwnerAccountID, (char *)extension.items + 1, 2); + groupOwnerAccountID = OFFromLittleEndian16(groupOwnerAccountID); + + memcpy(&ownerAccountID, (char *)extension.items + 3, 2); + ownerAccountID = OFFromLittleEndian16(ownerAccountID); + + [entry->_groupOwnerAccountID release]; + entry->_groupOwnerAccountID = nil; + + [entry->_ownerAccountID release]; + entry->_ownerAccountID = nil; + + entry->_groupOwnerAccountID = + [[OFNumber alloc] initWithUnsignedShort: groupOwnerAccountID]; + entry->_ownerAccountID = + [[OFNumber alloc] initWithUnsignedShort: ownerAccountID]; } static void parseGroupExtension(OFLHAArchiveEntry *entry, OFData *extension, OFStringEncoding encoding) { - [entry->_group release]; - entry->_group = nil; + [entry->_groupOwnerAccountName release]; + entry->_groupOwnerAccountName = nil; - entry->_group = [[OFString alloc] + entry->_groupOwnerAccountName = [[OFString alloc] initWithCString: (char *)extension.items + 1 encoding: encoding length: extension.count - 1]; } static void parseOwnerExtension(OFLHAArchiveEntry *entry, OFData *extension, OFStringEncoding encoding) { - [entry->_owner release]; - entry->_owner = nil; + [entry->_ownerAccountName release]; + entry->_ownerAccountName = nil; - entry->_owner = [[OFString alloc] + entry->_ownerAccountName = [[OFString alloc] initWithCString: (char *)extension.items + 1 encoding: encoding length: extension.count - 1]; } @@ -416,15 +419,15 @@ [_compressionMethod release]; [_fileName release]; [_directoryName release]; [_modificationDate release]; [_fileComment release]; - [_mode release]; - [_UID release]; - [_GID release]; - [_owner release]; - [_group release]; + [_POSIXPermissions release]; + [_ownerAccountID release]; + [_groupOwnerAccountID release]; + [_ownerAccountName release]; + [_groupOwnerAccountName release]; [_extensions release]; [super dealloc]; } @@ -452,15 +455,15 @@ 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->_POSIXPermissions = [_POSIXPermissions retain]; + copy->_ownerAccountID = [_ownerAccountID retain]; + copy->_groupOwnerAccountID = [_groupOwnerAccountID retain]; + copy->_ownerAccountName = [_ownerAccountName copy]; + copy->_groupOwnerAccountName = [_groupOwnerAccountName copy]; copy->_extensions = [_extensions copy]; } @catch (id e) { [copy release]; @throw e; } @@ -514,33 +517,33 @@ - (OFString *)fileComment { return _fileComment; } -- (OFNumber *)mode -{ - return _mode; -} - -- (OFNumber *)UID -{ - return _UID; -} - -- (OFNumber *)GID -{ - return _GID; -} - -- (OFString *)owner -{ - return _owner; -} - -- (OFString *)group -{ - return _group; +- (OFNumber *)POSIXPermissions +{ + return _POSIXPermissions; +} + +- (OFNumber *)ownerAccountID +{ + return _ownerAccountID; +} + +- (OFNumber *)groupOwnerAccountID +{ + return _groupOwnerAccountID; +} + +- (OFString *)ownerAccountName +{ + return _ownerAccountName; +} + +- (OFString *)groupOwnerAccountName +{ + return _groupOwnerAccountName; } - (OFArray OF_GENERIC(OFData *) *)extensions { return _extensions; @@ -629,60 +632,64 @@ [data addItem: "\x3F"]; [data addItems: [_fileComment cStringWithEncoding: encoding] count: fileCommentLength]; } - if (_mode != nil) { + if (_POSIXPermissions != nil) { tmp16 = OFToLittleEndian16(5); [data addItems: &tmp16 count: sizeof(tmp16)]; [data addItem: "\x50"]; - tmp16 = OFToLittleEndian16(_mode.unsignedShortValue); + tmp16 = + OFToLittleEndian16(_POSIXPermissions.unsignedShortValue); [data addItems: &tmp16 count: sizeof(tmp16)]; } - if (_UID != nil || _GID != nil) { - if (_UID == nil || _GID == nil) + if (_ownerAccountID != nil || _groupOwnerAccountID != nil) { + if (_ownerAccountID == nil || _groupOwnerAccountID == nil) @throw [OFInvalidArgumentException exception]; tmp16 = OFToLittleEndian16(7); [data addItems: &tmp16 count: sizeof(tmp16)]; [data addItem: "\x51"]; - tmp16 = OFToLittleEndian16(_GID.unsignedShortValue); + tmp16 = OFToLittleEndian16( + _groupOwnerAccountID.unsignedShortValue); [data addItems: &tmp16 count: sizeof(tmp16)]; - tmp16 = OFToLittleEndian16(_UID.unsignedShortValue); + tmp16 = OFToLittleEndian16(_ownerAccountID.unsignedShortValue); [data addItems: &tmp16 count: sizeof(tmp16)]; } - if (_group != nil) { - size_t groupLength = - [_group cStringLengthWithEncoding: encoding]; + if (_groupOwnerAccountName != nil) { + size_t length = [_groupOwnerAccountName + cStringLengthWithEncoding: encoding]; - if (groupLength > UINT16_MAX - 3) + if (length > UINT16_MAX - 3) @throw [OFOutOfRangeException exception]; - tmp16 = OFToLittleEndian16((uint16_t)groupLength + 3); + tmp16 = OFToLittleEndian16((uint16_t)length + 3); [data addItems: &tmp16 count: sizeof(tmp16)]; [data addItem: "\x52"]; - [data addItems: [_group cStringWithEncoding: encoding] - count: groupLength]; + [data addItems: [_groupOwnerAccountName + cStringWithEncoding: encoding] + count: length]; } - if (_owner != nil) { - size_t ownerLength = - [_owner cStringLengthWithEncoding: encoding]; + if (_ownerAccountName != nil) { + size_t length = + [_ownerAccountName cStringLengthWithEncoding: encoding]; - if (ownerLength > UINT16_MAX - 3) + if (length > UINT16_MAX - 3) @throw [OFOutOfRangeException exception]; - tmp16 = OFToLittleEndian16((uint16_t)ownerLength + 3); + tmp16 = OFToLittleEndian16((uint16_t)length + 3); [data addItems: &tmp16 count: sizeof(tmp16)]; [data addItem: "\x53"]; - [data addItems: [_owner cStringWithEncoding: encoding] - count: ownerLength]; + [data addItems: [_ownerAccountName + cStringWithEncoding: encoding] + count: length]; } for (OFData *extension in _extensions) { size_t extensionLength = extension.count; @@ -719,16 +726,21 @@ } - (OFString *)description { void *pool = objc_autoreleasePoolPush(); - OFString *mode = (_mode == nil ? nil - : [OFString stringWithFormat: @"%ho", _mode.unsignedShortValue]); + OFString *POSIXPermissions = nil; OFString *extensions = [_extensions.description stringByReplacingOccurrencesOfString: @"\n" withString: @"\n\t"]; - OFString *ret = [OFString stringWithFormat: + OFString *ret; + + if (_POSIXPermissions != nil) + POSIXPermissions = [OFString stringWithFormat: @"%ho", + _POSIXPermissions.unsignedShortValue]; + + ret = [OFString stringWithFormat: @"<%@:\n" @"\tFile name = %@\n" @"\tCompression method = %@\n" @"\tCompressed size = %llu\n" @"\tUncompressed size = %llu\n" @@ -735,24 +747,25 @@ @"\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" + @"\tPOSIX permissions = %@\n" + @"\tOwner account ID = %@\n" + @"\tGroup owner account ID = %@\n" + @"\tOwner account name = %@\n" + @"\tGroup owner accounut name = %@\n" @"\tExtensions: %@" @">", self.class, self.fileName, _compressionMethod, _compressedSize, _uncompressedSize, _modificationDate, _headerLevel, _CRC16, - _operatingSystemIdentifier, _fileComment, mode, _UID, _GID, _owner, - _group, extensions]; + _operatingSystemIdentifier, _fileComment, POSIXPermissions, + _ownerAccountID, _groupOwnerAccountID, _ownerAccountName, + _groupOwnerAccountName, extensions]; [ret retain]; objc_autoreleasePoolPop(pool); return [ret autorelease]; } @end