Index: src/OFMutableTarArchiveEntry.h ================================================================== --- src/OFMutableTarArchiveEntry.h +++ src/OFMutableTarArchiveEntry.h @@ -30,21 +30,21 @@ } /** * @brief The mode of the entry. */ -@property (readwrite, nonatomic) unsigned long mode; +@property (readwrite, retain, nonatomic) OFNumber *mode; /** * @brief The UID of the owner. */ -@property (readwrite, nonatomic) unsigned long UID; +@property (readwrite, retain, nonatomic) OFNumber *UID; /** * @brief The GID of the group. */ -@property (readwrite, nonatomic) unsigned long GID; +@property (readwrite, retain, nonatomic) OFNumber *GID; /** * @brief The date of the last modification of the file. */ @property (readwrite, retain, nonatomic) OFDate *modificationDate; Index: src/OFMutableTarArchiveEntry.m ================================================================== --- src/OFMutableTarArchiveEntry.m +++ src/OFMutableTarArchiveEntry.m @@ -15,12 +15,13 @@ #include "config.h" #import "OFMutableTarArchiveEntry.h" #import "OFTarArchiveEntry+Private.h" -#import "OFString.h" #import "OFDate.h" +#import "OFNumber.h" +#import "OFString.h" @implementation OFMutableTarArchiveEntry @dynamic fileName, mode, UID, GID, compressedSize, uncompressedSize; @dynamic modificationDate, type, targetFileName, owner, group, deviceMajor; @dynamic deviceMinor; @@ -58,23 +59,29 @@ OFString *old = _fileName; _fileName = [fileName copy]; [old release]; } -- (void)setMode: (unsigned long)mode +- (void)setMode: (OFNumber *)mode { - _mode = mode; + OFNumber *old = _mode; + _mode = [mode retain]; + [old release]; } -- (void)setUID: (unsigned long)UID +- (void)setUID: (OFNumber *)UID { - _UID = UID; + OFNumber *old = _UID; + _UID = [UID retain]; + [old release]; } -- (void)setGID: (unsigned long)GID +- (void)setGID: (OFNumber *)GID { - _GID = GID; + OFNumber *old = _GID; + _GID = [GID retain]; + [old release]; } - (void)setCompressedSize: (unsigned long long)compressedSize { _compressedSize = compressedSize; Index: src/OFTarArchiveEntry.h ================================================================== --- src/OFTarArchiveEntry.h +++ src/OFTarArchiveEntry.h @@ -19,10 +19,11 @@ OF_ASSUME_NONNULL_BEGIN /** @file */ @class OFDate; +@class OFNumber; /** * @brief The type of the archive entry. */ typedef enum { @@ -51,13 +52,12 @@ */ @interface OFTarArchiveEntry: OFObject { OFString *_fileName; - unsigned long _mode; + OFNumber *_mode, *_UID, *_GID; unsigned long long _compressedSize, _uncompressedSize; - unsigned long _UID, _GID; OFDate *_modificationDate; OFTarArchiveEntryType _type; OFString *_Nullable _targetFileName; OFString *_Nullable _owner, *_Nullable _group; unsigned long _deviceMajor, _deviceMinor; @@ -65,21 +65,21 @@ } /** * @brief The mode of the entry. */ -@property (readonly, nonatomic) unsigned long mode; +@property (readonly, retain, nonatomic) OFNumber *mode; /** * @brief The UID of the owner. */ -@property (readonly, nonatomic) unsigned long UID; +@property (readonly, retain, nonatomic) OFNumber *UID; /** * @brief The GID of the group. */ -@property (readonly, nonatomic) unsigned long GID; +@property (readonly, retain, nonatomic) OFNumber *GID; /** * @brief The date of the last modification of the file. */ @property (readonly, retain, nonatomic) OFDate *modificationDate; Index: src/OFTarArchiveEntry.m ================================================================== --- src/OFTarArchiveEntry.m +++ src/OFTarArchiveEntry.m @@ -16,10 +16,11 @@ #include "config.h" #import "OFTarArchiveEntry.h" #import "OFTarArchiveEntry+Private.h" #import "OFDate.h" +#import "OFNumber.h" #import "OFStream.h" #import "OFString.h" #import "OFOutOfRangeException.h" @@ -81,12 +82,17 @@ - (instancetype)of_init { self = [super init]; - _type = OFTarArchiveEntryTypeFile; - _mode = 0644; + @try { + _type = OFTarArchiveEntryTypeFile; + _mode = [[OFNumber alloc] initWithUnsignedShort: 0644]; + } @catch (id e) { + [self release]; + @throw e; + } return self; } - (instancetype)of_initWithHeader: (unsigned char [512])header @@ -97,16 +103,16 @@ @try { void *pool = objc_autoreleasePoolPush(); OFString *targetFileName; _fileName = [stringFromBuffer(header, 100, encoding) copy]; - _mode = (unsigned long)octalValueFromBuffer( - header + 100, 8, ULONG_MAX); - _UID = (unsigned long)octalValueFromBuffer( - header + 108, 8, ULONG_MAX); - _GID = (unsigned long)octalValueFromBuffer( - header + 116, 8, ULONG_MAX); + _mode = [[OFNumber alloc] initWithUnsignedLongLong: + octalValueFromBuffer(header + 100, 8, ULONG_MAX)]; + _UID = [[OFNumber alloc] initWithUnsignedLongLong: + octalValueFromBuffer(header + 108, 8, ULONG_MAX)]; + _GID = [[OFNumber alloc] initWithUnsignedLongLong: + octalValueFromBuffer(header + 116, 8, ULONG_MAX)]; _uncompressedSize = (unsigned long long)octalValueFromBuffer( header + 124, 12, ULLONG_MAX); _compressedSize = _uncompressedSize + (512 - _uncompressedSize % 512); _modificationDate = [[OFDate alloc] @@ -155,10 +161,13 @@ } - (void)dealloc { [_fileName release]; + [_mode release]; + [_UID release]; + [_GID release]; [_modificationDate release]; [_targetFileName release]; [_owner release]; [_group release]; @@ -197,21 +206,21 @@ - (OFString *)fileName { return _fileName; } -- (unsigned long)mode +- (OFNumber *)mode { return _mode; } -- (unsigned long)UID +- (OFNumber *)UID { return _UID; } -- (unsigned long)GID +- (OFNumber *)GID { return _GID; } - (unsigned long long)compressedSize Index: utils/ofarc/TarArchive.m ================================================================== --- utils/ofarc/TarArchive.m +++ utils/ofarc/TarArchive.m @@ -31,11 +31,12 @@ static void setPermissions(OFString *path, OFTarArchiveEntry *entry) { #ifdef OF_FILE_MANAGER_SUPPORTS_PERMISSIONS - OFNumber *mode = [OFNumber numberWithUnsignedShort: entry.mode & 0777]; + OFNumber *mode = [OFNumber numberWithUnsignedLongLong: + entry.mode.longLongValue & 0777]; OFFileAttributes attributes = [OFDictionary dictionaryWithObject: mode forKey: OFFilePOSIXPermissions]; [[OFFileManager defaultManager] setAttributes: attributes @@ -115,15 +116,13 @@ OFString *date = [entry.modificationDate localDateStringWithFormat: @"%Y-%m-%d %H:%M:%S"]; OFString *size = [OFString stringWithFormat: @"%llu", entry.uncompressedSize]; OFString *mode = [OFString stringWithFormat: - @"%06o", entry.mode]; - OFString *UID = [OFString stringWithFormat: - @"%u", entry.UID]; - OFString *GID = [OFString stringWithFormat: - @"%u", entry.GID]; + @"%06llo", entry.mode.unsignedLongLongValue]; + OFString *UID = entry.UID.description; + OFString *GID = entry.GID.description; [OFStdOut writeString: @"\t"]; [OFStdOut writeLine: OF_LOCALIZED(@"list_size", @"[" @" 'Size: '," @@ -477,18 +476,19 @@ attributes = [fileManager attributesOfItemAtPath: fileName]; type = attributes.fileType; entry = [OFMutableTarArchiveEntry entryWithFileName: fileName]; #ifdef OF_FILE_MANAGER_SUPPORTS_PERMISSIONS - entry.mode = attributes.filePOSIXPermissions; + entry.mode = [attributes objectForKey: OFFilePOSIXPermissions]; #endif entry.uncompressedSize = attributes.fileSize; entry.modificationDate = attributes.fileModificationDate; #ifdef OF_FILE_MANAGER_SUPPORTS_OWNER - entry.UID = attributes.fileOwnerAccountID; - entry.GID = attributes.fileGroupOwnerAccountID; + entry.UID = [attributes objectForKey: OFFileOwnerAccountID]; + entry.GID = + [attributes objectForKey: OFFileGroupOwnerAccountID]; entry.owner = attributes.fileOwnerAccountName; entry.group = attributes.fileGroupOwnerAccountName; #endif if ([type isEqual: OFFileTypeRegular])