Differences From Artifact [e3da7730a5]:
- File
src/OFTarArchiveEntry.m
— part of check-in
[f9cd4f9cab]
at
2017-06-05 15:51:48
on branch trunk
— OFStream: Don't throw when at end of stream
Instead, let reads return 0 and let writes append after the end. (user: js, size: 4953) [annotate] [blame] [check-ins using]
To Artifact [9618c37951]:
- File
src/OFTarArchiveEntry.m
— part of check-in
[3f34a360bf]
at
2017-08-05 12:27:30
on branch trunk
— Add OFMutableTarArchiveEntry
This is in preparation for OFTarArchive write support. (user: js, size: 4841) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
10 11 12 13 14 15 16 | * * Alternatively, it may be distributed under the terms of the GNU General * Public License, either version 2 or 3, which can be found in the file * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ | < < < | 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | * * Alternatively, it may be distributed under the terms of the GNU General * Public License, either version 2 or 3, which can be found in the file * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ #include "config.h" #include <inttypes.h> #import "OFTarArchiveEntry.h" #import "OFTarArchiveEntry+Private.h" #import "OFStream.h" #import "OFDate.h" #import "OFOutOfRangeException.h" static OFString * stringFromBuffer(const char *buffer, size_t length) { for (size_t i = 0; i < length; i++) if (buffer[i] == '\0') |
︙ | ︙ | |||
47 48 49 50 51 52 53 | if (value > max) @throw [OFOutOfRangeException exception]; return value; } @implementation OFTarArchiveEntry | | < > | < < > < | < | > | > > | 44 45 46 47 48 49 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 88 89 | if (value > max) @throw [OFOutOfRangeException exception]; return value; } @implementation OFTarArchiveEntry + (instancetype)entryWithFileName: (OFString *)fileName { return [[[self alloc] initWithFileName: fileName] autorelease]; } - init { OF_INVALID_INIT_METHOD } - (instancetype)of_initWithHeader: (char [512])header { self = [super init]; @try { void *pool = objc_autoreleasePoolPush(); OFString *targetFileName; _fileName = [stringFromBuffer(header, 100) copy]; _mode = (uint32_t)octalValueFromBuffer( header + 100, 8, UINT32_MAX); _size = (uint64_t)octalValueFromBuffer( header + 124, 12, UINT64_MAX); _modificationDate = [[OFDate alloc] initWithTimeIntervalSince1970: (of_time_interval_t)octalValueFromBuffer( header + 136, 12, UINTMAX_MAX)]; _type = header[156]; targetFileName = stringFromBuffer(header + 157, 100); if ([targetFileName length] > 0) _targetFileName = [targetFileName copy]; if (_type == '\0') _type = OF_TAR_ARCHIVE_ENTRY_TYPE_FILE; if (memcmp(header + 257, "ustar\0" "00", 8) == 0) { OFString *fileName; |
︙ | ︙ | |||
108 109 110 111 112 113 114 115 116 117 | } @catch (id e) { [self release]; @throw e; } return self; } - (void)dealloc { | > > > > > > > > > > > > > > < < | < | | | < > | > | < > | | > > > > > > > > > > | < < | < | | > | | | | < | < | > | > > | > | | < | | < | > | < > > | > > | | | < | < > > | < < < | > > | < | < > > | 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 | } @catch (id e) { [self release]; @throw e; } return self; } - initWithFileName: (OFString *)fileName { self = [super init]; @try { _fileName = [fileName copy]; } @catch (id e) { [self release]; @throw e; } return self; } - (void)dealloc { [_fileName release]; [_modificationDate release]; [_targetFileName release]; [_owner release]; [_group release]; [super dealloc]; } - copy { return [self retain]; } - mutableCopy { OFTarArchiveEntry *copy = [[OFMutableTarArchiveEntry alloc] initWithFileName: _fileName]; @try { copy->_mode = _mode; copy->_size = _size; copy->_modificationDate = [_modificationDate copy]; copy->_type = _type; copy->_targetFileName = [_targetFileName copy]; copy->_owner = [_owner copy]; copy->_group = [_group copy]; copy->_deviceMajor = _deviceMajor; copy->_deviceMinor = _deviceMinor; } @catch (id e) { [copy release]; @throw e; } return copy; } - (OFString *)fileName { return _fileName; } - (uint32_t)mode { return _mode; } - (uint64_t)size { return _size; } - (OFDate *)modificationDate { return _modificationDate; } - (of_tar_archive_entry_type_t)type { return _type; } - (OFString *)targetFileName { return _targetFileName; } - (OFString *)owner { return _owner; } - (OFString *)group { return _group; } - (uint32_t)deviceMajor { return _deviceMajor; } - (uint32_t)deviceMinor { return _deviceMinor; } - (OFString *)description { void *pool = objc_autoreleasePoolPush(); OFString *ret = [OFString stringWithFormat: @"<%@:\n" @"\tFile name = %@\n" |
︙ | ︙ |