Overview
Comment: | OFTarArchiveEntry: Make mode/UID/GID an OFNumber
This is for consistency with OFLHAArchiveEntry. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
d281c3198b4432f4641ba2c72cd76602 |
User & Date: | js on 2022-08-27 22:29:44 |
Other Links: | manifest | tags |
Context
2022-08-27
| ||
23:53 | OFArchiveEntry: Add more properties check-in: 406134b5e2 user: js tags: trunk | |
22:29 | OFTarArchiveEntry: Make mode/UID/GID an OFNumber check-in: d281c3198b user: js tags: trunk | |
21:42 | Make GCC happy again check-in: 7094055a27 user: js tags: trunk | |
Changes
Modified src/OFMutableTarArchiveEntry.h from [7139e7f4ec] to [d942abe401].
︙ | ︙ | |||
28 29 30 31 32 33 34 | { OF_RESERVE_IVARS(OFMutableTarArchiveEntry, 4) } /** * @brief The mode of the entry. */ | | | | | 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | { OF_RESERVE_IVARS(OFMutableTarArchiveEntry, 4) } /** * @brief The mode of the entry. */ @property (readwrite, retain, nonatomic) OFNumber *mode; /** * @brief The UID of the owner. */ @property (readwrite, retain, nonatomic) OFNumber *UID; /** * @brief The GID of the group. */ @property (readwrite, retain, nonatomic) OFNumber *GID; /** * @brief The date of the last modification of the file. */ @property (readwrite, retain, nonatomic) OFDate *modificationDate; /** |
︙ | ︙ |
Modified src/OFMutableTarArchiveEntry.m from [5cc47d2692] to [c563d173e3].
︙ | ︙ | |||
13 14 15 16 17 18 19 | * file. */ #include "config.h" #import "OFMutableTarArchiveEntry.h" #import "OFTarArchiveEntry+Private.h" | | | > | 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | * file. */ #include "config.h" #import "OFMutableTarArchiveEntry.h" #import "OFTarArchiveEntry+Private.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; + (instancetype)entryWithFileName: (OFString *)fileName |
︙ | ︙ | |||
56 57 58 59 60 61 62 | - (void)setFileName: (OFString *)fileName { OFString *old = _fileName; _fileName = [fileName copy]; [old release]; } | | > | > | > | > | > | > | 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 | - (void)setFileName: (OFString *)fileName { OFString *old = _fileName; _fileName = [fileName copy]; [old release]; } - (void)setMode: (OFNumber *)mode { OFNumber *old = _mode; _mode = [mode retain]; [old release]; } - (void)setUID: (OFNumber *)UID { OFNumber *old = _UID; _UID = [UID retain]; [old release]; } - (void)setGID: (OFNumber *)GID { OFNumber *old = _GID; _GID = [GID retain]; [old release]; } - (void)setCompressedSize: (unsigned long long)compressedSize { _compressedSize = compressedSize; } |
︙ | ︙ |
Modified src/OFTarArchiveEntry.h from [bbf42fa9c7] to [bbe0bc8d5f].
︙ | ︙ | |||
17 18 19 20 21 22 23 24 25 26 27 28 29 30 | #import "OFArchiveEntry.h" OF_ASSUME_NONNULL_BEGIN /** @file */ @class OFDate; /** * @brief The type of the archive entry. */ typedef enum { /** Normal file */ OFTarArchiveEntryTypeFile = '0', | > | 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | #import "OFArchiveEntry.h" OF_ASSUME_NONNULL_BEGIN /** @file */ @class OFDate; @class OFNumber; /** * @brief The type of the archive entry. */ typedef enum { /** Normal file */ OFTarArchiveEntryTypeFile = '0', |
︙ | ︙ | |||
49 50 51 52 53 54 55 | * * @brief A class which represents an entry of a tar archive. */ @interface OFTarArchiveEntry: OFObject <OFArchiveEntry, OFCopying, OFMutableCopying> { OFString *_fileName; | | < | | | | 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 | * * @brief A class which represents an entry of a tar archive. */ @interface OFTarArchiveEntry: OFObject <OFArchiveEntry, OFCopying, OFMutableCopying> { OFString *_fileName; OFNumber *_mode, *_UID, *_GID; unsigned long long _compressedSize, _uncompressedSize; OFDate *_modificationDate; OFTarArchiveEntryType _type; OFString *_Nullable _targetFileName; OFString *_Nullable _owner, *_Nullable _group; unsigned long _deviceMajor, _deviceMinor; OF_RESERVE_IVARS(OFTarArchiveEntry, 4) } /** * @brief The mode of the entry. */ @property (readonly, retain, nonatomic) OFNumber *mode; /** * @brief The UID of the owner. */ @property (readonly, retain, nonatomic) OFNumber *UID; /** * @brief The GID of the group. */ @property (readonly, retain, nonatomic) OFNumber *GID; /** * @brief The date of the last modification of the file. */ @property (readonly, retain, nonatomic) OFDate *modificationDate; /** |
︙ | ︙ |
Modified src/OFTarArchiveEntry.m from [f5a88ae9e6] to [91a459baa0].
︙ | ︙ | |||
14 15 16 17 18 19 20 21 22 23 24 25 26 27 | */ #include "config.h" #import "OFTarArchiveEntry.h" #import "OFTarArchiveEntry+Private.h" #import "OFDate.h" #import "OFStream.h" #import "OFString.h" #import "OFOutOfRangeException.h" static OFString * stringFromBuffer(const unsigned char *buffer, size_t length, | > | 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | */ #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" static OFString * stringFromBuffer(const unsigned char *buffer, size_t length, |
︙ | ︙ | |||
79 80 81 82 83 84 85 | OF_INVALID_INIT_METHOD } - (instancetype)of_init { self = [super init]; | > | | > > > > | | | | | | | 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 | OF_INVALID_INIT_METHOD } - (instancetype)of_init { self = [super init]; @try { _type = OFTarArchiveEntryTypeFile; _mode = [[OFNumber alloc] initWithUnsignedShort: 0644]; } @catch (id e) { [self release]; @throw e; } return self; } - (instancetype)of_initWithHeader: (unsigned char [512])header encoding: (OFStringEncoding)encoding { self = [super init]; @try { void *pool = objc_autoreleasePoolPush(); OFString *targetFileName; _fileName = [stringFromBuffer(header, 100, encoding) copy]; _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] initWithTimeIntervalSince1970: (OFTimeInterval)octalValueFromBuffer( |
︙ | ︙ | |||
153 154 155 156 157 158 159 160 161 162 163 164 165 166 | return self; } - (void)dealloc { [_fileName release]; [_modificationDate release]; [_targetFileName release]; [_owner release]; [_group release]; [super dealloc]; } | > > > | 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 | return self; } - (void)dealloc { [_fileName release]; [_mode release]; [_UID release]; [_GID release]; [_modificationDate release]; [_targetFileName release]; [_owner release]; [_group release]; [super dealloc]; } |
︙ | ︙ | |||
195 196 197 198 199 200 201 | } - (OFString *)fileName { return _fileName; } | | | | | 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 | } - (OFString *)fileName { return _fileName; } - (OFNumber *)mode { return _mode; } - (OFNumber *)UID { return _UID; } - (OFNumber *)GID { return _GID; } - (unsigned long long)compressedSize { return _compressedSize; |
︙ | ︙ |
Modified utils/ofarc/TarArchive.m from [ed3299d668] to [e32d96f125].
︙ | ︙ | |||
29 30 31 32 33 34 35 | static OFArc *app; static void setPermissions(OFString *path, OFTarArchiveEntry *entry) { #ifdef OF_FILE_MANAGER_SUPPORTS_PERMISSIONS | | > | 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | static OFArc *app; static void setPermissions(OFString *path, OFTarArchiveEntry *entry) { #ifdef OF_FILE_MANAGER_SUPPORTS_PERMISSIONS OFNumber *mode = [OFNumber numberWithUnsignedLongLong: entry.mode.longLongValue & 0777]; OFFileAttributes attributes = [OFDictionary dictionaryWithObject: mode forKey: OFFilePOSIXPermissions]; [[OFFileManager defaultManager] setAttributes: attributes ofItemAtPath: path]; #endif |
︙ | ︙ | |||
113 114 115 116 117 118 119 | if (app->_outputLevel >= 1) { OFString *date = [entry.modificationDate localDateStringWithFormat: @"%Y-%m-%d %H:%M:%S"]; OFString *size = [OFString stringWithFormat: @"%llu", entry.uncompressedSize]; OFString *mode = [OFString stringWithFormat: | | | < | < | 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 | if (app->_outputLevel >= 1) { OFString *date = [entry.modificationDate localDateStringWithFormat: @"%Y-%m-%d %H:%M:%S"]; OFString *size = [OFString stringWithFormat: @"%llu", entry.uncompressedSize]; OFString *mode = [OFString stringWithFormat: @"%06llo", entry.mode.unsignedLongLongValue]; OFString *UID = entry.UID.description; OFString *GID = entry.GID.description; [OFStdOut writeString: @"\t"]; [OFStdOut writeLine: OF_LOCALIZED(@"list_size", @"[" @" 'Size: '," @" [" @" {'size == 1': '1 byte'}," |
︙ | ︙ | |||
475 476 477 478 479 480 481 | @"file", fileName)]; attributes = [fileManager attributesOfItemAtPath: fileName]; type = attributes.fileType; entry = [OFMutableTarArchiveEntry entryWithFileName: fileName]; #ifdef OF_FILE_MANAGER_SUPPORTS_PERMISSIONS | | | | > | 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 | @"file", fileName)]; attributes = [fileManager attributesOfItemAtPath: fileName]; type = attributes.fileType; entry = [OFMutableTarArchiveEntry entryWithFileName: fileName]; #ifdef OF_FILE_MANAGER_SUPPORTS_PERMISSIONS entry.mode = [attributes objectForKey: OFFilePOSIXPermissions]; #endif entry.uncompressedSize = attributes.fileSize; entry.modificationDate = attributes.fileModificationDate; #ifdef OF_FILE_MANAGER_SUPPORTS_OWNER entry.UID = [attributes objectForKey: OFFileOwnerAccountID]; entry.GID = [attributes objectForKey: OFFileGroupOwnerAccountID]; entry.owner = attributes.fileOwnerAccountName; entry.group = attributes.fileGroupOwnerAccountName; #endif if ([type isEqual: OFFileTypeRegular]) entry.type = OFTarArchiveEntryTypeFile; else if ([type isEqual: OFFileTypeDirectory]) { |
︙ | ︙ |