127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
|
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
|
+
-
+
-
-
-
+
+
|
if (_type == '\0')
_type = OFTarArchiveEntryTypeFile;
if (memcmp(header + 257, "ustar\0" "00", 8) == 0) {
OFString *prefix;
_ownerAccountName =
_owner = [stringFromBuffer(header + 265, 32, encoding)
[stringFromBuffer(header + 265, 32, encoding) copy];
copy];
_group = [stringFromBuffer(header + 297, 32, encoding)
copy];
_groupOwnerAccountName = [stringFromBuffer(header + 297,
32, encoding) copy];
_deviceMajor = (unsigned long)octalValueFromBuffer(
header + 329, 8, ULONG_MAX);
_deviceMinor = (unsigned long)octalValueFromBuffer(
header + 337, 8, ULONG_MAX);
prefix = stringFromBuffer(header + 345, 155, encoding);
|
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
|
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
|
-
+
-
+
-
+
-
+
+
+
+
+
+
+
-
+
-
-
-
+
+
+
-
-
+
+
-
-
-
+
+
+
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
|
}
- (OFString *)targetFileName
{
return _targetFileName;
}
- (OFString *)owner
- (OFString *)ownerAccountName
{
return _owner;
return _ownerAccountName;
}
- (OFString *)group
- (OFString *)groupOwnerAccountName
{
return _group;
return _groupOwnerAccountName;
}
- (unsigned long)deviceMajor
{
return _deviceMajor;
}
- (unsigned long)deviceMinor
{
return _deviceMinor;
}
- (OFString *)description
{
void *pool = objc_autoreleasePoolPush();
OFString *POSIXPermissions = nil, *ret;
if (_POSIXPermissions != nil)
POSIXPermissions = [OFString stringWithFormat: @"%ho",
_POSIXPermissions.unsignedShortValue];
OFString *ret = [OFString stringWithFormat: @"<%@:\n"
ret = [OFString stringWithFormat: @"<%@:\n"
@"\tFile name = %@\n"
@"\tMode = %06o\n"
@"\tUID = %u\n"
@"\tGID = %u\n"
@"\tPOSIX permissions = %@\n"
@"\tOwner account ID = %@\n"
@"\tGroup owner account ID = %@\n"
@"\tCompressed size = %llu\n"
@"\tUncompressed size = %llu\n"
@"\tModification date = %@\n"
@"\tType = %u\n"
@"\tTarget file name = %@\n"
@"\tOwner = %@\n"
@"\tGroup = %@\n"
@"\tOwner account name = %@\n"
@"\tGroup owner account name = %@\n"
@"\tDevice major = %" PRIu32 @"\n"
@"\tDevice minor = %" PRIu32 @"\n"
@">",
self.class, _fileName, _mode, _UID, _GID, _compressedSize,
_uncompressedSize, _modificationDate, _type, _targetFileName,
_owner, _group, _deviceMajor, _deviceMinor];
self.class, _fileName, POSIXPermissions, _ownerAccountID,
_groupOwnerAccountID, _compressedSize, _uncompressedSize,
_modificationDate, _type, _targetFileName,
_ownerAccountName, _groupOwnerAccountName, _deviceMajor,
_deviceMinor];
[ret retain];
objc_autoreleasePoolPop(pool);
return [ret autorelease];
}
- (void)of_writeToStream: (OFStream *)stream
encoding: (OFStringEncoding)encoding
{
unsigned char buffer[512];
unsigned long long modificationDate;
uint16_t checksum = 0;
stringToBuffer(buffer, _fileName, 100, encoding);
stringToBuffer(buffer + 100,
[OFString stringWithFormat: @"%06" PRIo16 " ", _mode], 8,
OFStringEncodingASCII);
[OFString stringWithFormat: @"%06o ",
_POSIXPermissions.unsignedShortValue], 8, OFStringEncodingASCII);
stringToBuffer(buffer + 108,
[OFString stringWithFormat: @"%06" PRIo16 " ", _UID], 8,
OFStringEncodingASCII);
[OFString stringWithFormat: @"%06o ",
_ownerAccountID.unsignedShortValue], 8, OFStringEncodingASCII);
stringToBuffer(buffer + 116,
[OFString stringWithFormat: @"%06" PRIo16 " ", _GID], 8,
OFStringEncodingASCII);
[OFString stringWithFormat: @"%06o ",
_groupOwnerAccountID.unsignedShortValue], 8, OFStringEncodingASCII);
stringToBuffer(buffer + 124,
[OFString stringWithFormat: @"%011llo ", _uncompressedSize], 12,
OFStringEncodingASCII);
modificationDate = _modificationDate.timeIntervalSince1970;
stringToBuffer(buffer + 136,
[OFString stringWithFormat: @"%011llo", modificationDate],
12, OFStringEncodingASCII);
/*
* During checksumming, the checksum field is expected to be set to 8
* spaces.
*/
memset(buffer + 148, ' ', 8);
buffer[156] = _type;
stringToBuffer(buffer + 157, _targetFileName, 100, encoding);
/* ustar */
memcpy(buffer + 257, "ustar\0" "00", 8);
stringToBuffer(buffer + 265, _owner, 32, encoding);
stringToBuffer(buffer + 297, _group, 32, encoding);
stringToBuffer(buffer + 265, _ownerAccountName, 32, encoding);
stringToBuffer(buffer + 297, _groupOwnerAccountName, 32, encoding);
stringToBuffer(buffer + 329,
[OFString stringWithFormat: @"%06" PRIo32 " ", _deviceMajor], 8,
OFStringEncodingASCII);
stringToBuffer(buffer + 337,
[OFString stringWithFormat: @"%06" PRIo32 " ", _deviceMinor], 8,
OFStringEncodingASCII);
memset(buffer + 345, '\0', 155 + 12);
|