ObjFW  Check-in [8c00ffb513]

Overview
Comment:OFTarArchiveEntry: Add UID and GID
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 8c00ffb5134653d9e4f22ecd7d7b0eb45b4aa1fdbf749f56cf50ac4b13a4395f
User & Date: js on 2017-08-06 22:09:44
Other Links: manifest | tags
Context
2017-08-06
22:21
Add -[OFFileManager getUID:GID:ofItemAtPath:] check-in: 639dd9c244 user: js tags: trunk
22:09
OFTarArchiveEntry: Add UID and GID check-in: 8c00ffb513 user: js tags: trunk
21:45
OFTarArchiveEntry: Minor refactoring check-in: a6b87a1a0c user: js tags: trunk
Changes

Modified src/OFMutableTarArchiveEntry.h from [47bcdec64f] to [8b78b2c597].

30
31
32
33
34
35
36
37










38
39
40
41
42
43
44
 * The file name of the entry.
 */
@property (readwrite, nonatomic, copy) OFString *fileName;

/*!
 * The mode of the entry.
 */
@property (readwrite, nonatomic) uint32_t mode;











/*!
 * The size of the file.
 */
@property (readwrite, nonatomic) uint64_t size;

/*!







|
>
>
>
>
>
>
>
>
>
>







30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
 * The file name of the entry.
 */
@property (readwrite, nonatomic, copy) OFString *fileName;

/*!
 * The mode of the entry.
 */
@property (readwrite, nonatomic) uint16_t mode;

/*!
 * The UID of the owner.
 */
@property (readwrite, nonatomic) uint16_t UID;

/*!
 * The GID of the group.
 */
@property (readwrite, nonatomic) uint16_t GID;

/*!
 * The size of the file.
 */
@property (readwrite, nonatomic) uint64_t size;

/*!

Modified src/OFMutableTarArchiveEntry.m from [18a5b3f559] to [ee2d882217].

15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44










45
46
47
48
49
50
51
 */

#include "config.h"

#import "OFMutableTarArchiveEntry.h"

@implementation OFMutableTarArchiveEntry
@dynamic fileName, mode, size, modificationDate, type, targetFileName;
@dynamic owner, group, deviceMajor, deviceMinor;

- copy
{
	OFMutableTarArchiveEntry *copy = [self mutableCopy];

	[copy makeImmutable];

	return copy;
}

- (void)setFileName: (OFString *)fileName
{
	OFString *old = _fileName;
	_fileName = [fileName copy];
	[old release];
}

- (void)setMode: (uint32_t)mode
{
	_mode = mode;
}











- (void)setSize: (uint64_t)size
{
	_size = size;
}

- (void)setModificationDate: (OFDate *)modificationDate







|


















|



>
>
>
>
>
>
>
>
>
>







15
16
17
18
19
20
21
22
23
24
25
26
27
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
53
54
55
56
57
58
59
60
61
 */

#include "config.h"

#import "OFMutableTarArchiveEntry.h"

@implementation OFMutableTarArchiveEntry
@dynamic fileName, mode, UID, GID, size, modificationDate, type, targetFileName;
@dynamic owner, group, deviceMajor, deviceMinor;

- copy
{
	OFMutableTarArchiveEntry *copy = [self mutableCopy];

	[copy makeImmutable];

	return copy;
}

- (void)setFileName: (OFString *)fileName
{
	OFString *old = _fileName;
	_fileName = [fileName copy];
	[old release];
}

- (void)setMode: (uint16_t)mode
{
	_mode = mode;
}

- (void)setUID: (uint16_t)UID
{
	_UID = UID;
}

- (void)setGID: (uint16_t)GID
{
	_GID = GID;
}

- (void)setSize: (uint64_t)size
{
	_size = size;
}

- (void)setModificationDate: (OFDate *)modificationDate

Modified src/OFTarArchiveEntry.h from [cbb13e9f37] to [c4bac08a0d].

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
 * @class OFTarArchiveEntry OFTarArchiveEntry.h ObjFW/OFTarArchiveEntry.h
 *
 * @brief A class which represents an entry of a tar archive.
 */
@interface OFTarArchiveEntry: OFObject <OFCopying, OFMutableCopying>
{
	OFString *_fileName;
	uint32_t _mode;
	uint64_t _size;

	OFDate *_modificationDate;
	of_tar_archive_entry_type_t _type;
	OFString *_targetFileName;
	OFString *_owner, *_group;
	uint32_t _deviceMajor, _deviceMinor;
}

/*!
 * The file name of the entry.
 */
@property (readonly, nonatomic) OFString *fileName;

/*!
 * The mode of the entry.
 */
@property (readonly, nonatomic) uint32_t mode;











/*!
 * The size of the file.
 */
@property (readonly, nonatomic) uint64_t size;

/*!







|

>















|
>
>
>
>
>
>
>
>
>
>







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
 * @class OFTarArchiveEntry OFTarArchiveEntry.h ObjFW/OFTarArchiveEntry.h
 *
 * @brief A class which represents an entry of a tar archive.
 */
@interface OFTarArchiveEntry: OFObject <OFCopying, OFMutableCopying>
{
	OFString *_fileName;
	uint16_t _mode;
	uint64_t _size;
	uint16_t _UID, _GID;
	OFDate *_modificationDate;
	of_tar_archive_entry_type_t _type;
	OFString *_targetFileName;
	OFString *_owner, *_group;
	uint32_t _deviceMajor, _deviceMinor;
}

/*!
 * The file name of the entry.
 */
@property (readonly, nonatomic) OFString *fileName;

/*!
 * The mode of the entry.
 */
@property (readonly, nonatomic) uint16_t mode;

/*!
 * The UID of the owner.
 */
@property (readonly, nonatomic) uint16_t UID;

/*!
 * The GID of the group.
 */
@property (readonly, nonatomic) uint16_t GID;

/*!
 * The size of the file.
 */
@property (readonly, nonatomic) uint64_t size;

/*!

Modified src/OFTarArchiveEntry.m from [060412ff27] to [23b893292f].

77
78
79
80
81
82
83
84
85




86
87
88
89
90
91
92
	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];







|
|
>
>
>
>







77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
	self = [super init];

	@try {
		void *pool = objc_autoreleasePoolPush();
		OFString *targetFileName;

		_fileName = [stringFromBuffer(header, 100) copy];
		_mode = (uint16_t)octalValueFromBuffer(
		    header + 100, 8, UINT16_MAX);
		_UID = (uint16_t)octalValueFromBuffer(
		    header + 108, 8, UINT16_MAX);
		_GID = (uint16_t)octalValueFromBuffer(
		    header + 116, 8, UINT16_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];
184
185
186
187
188
189
190
191
192
193
194










195
196
197
198
199
200
201
}

- (OFString *)fileName
{
	return _fileName;
}

- (uint32_t)mode
{
	return _mode;
}











- (uint64_t)size
{
	return _size;
}

- (OFDate *)modificationDate







|



>
>
>
>
>
>
>
>
>
>







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
}

- (OFString *)fileName
{
	return _fileName;
}

- (uint16_t)mode
{
	return _mode;
}

- (uint16_t)UID
{
	return _UID;
}

- (uint16_t)GID
{
	return _GID;
}

- (uint64_t)size
{
	return _size;
}

- (OFDate *)modificationDate
235
236
237
238
239
240
241


242
243
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

- (OFString *)description
{
	void *pool = objc_autoreleasePoolPush();
	OFString *ret = [OFString stringWithFormat: @"<%@:\n"
	     @"\tFile name = %@\n"
	     @"\tMode = %06o\n"


	     @"\tSize = %" PRIu64 @"\n"
	     @"\tModification date = %@\n"
	     @"\tType = %u\n"
	     @"\tTarget file name = %@\n"
	     @"\tOwner = %@\n"
	     @"\tGroup = %@\n"
	     @"\tDevice major = %" PRIu32 @"\n"
	     @"\tDevice minor = %" PRIu32 @"\n"
	     @">",
	    [self class], _fileName, _mode, _size, _modificationDate, _type,

	    _targetFileName, _owner, _group, _deviceMajor, _deviceMinor];

	[ret retain];

	objc_autoreleasePoolPop(pool);

	return [ret autorelease];
}

- (void)of_writeToStream: (OFStream *)stream
{
	unsigned char buffer[512];
	uint64_t modificationDate;
	uint16_t checksum = 0;

	stringToBuffer(buffer, _fileName, 100);
	stringToBuffer(buffer + 100,
	    [OFString stringWithFormat: @"%06" PRIo32 " ", _mode], 8);
	memcpy(buffer + 108, "000000 \0" "000000 \0", 16);



	stringToBuffer(buffer + 124,
	    [OFString stringWithFormat: @"%011" PRIo64 " ", _size], 12);
	modificationDate = [_modificationDate timeIntervalSince1970];
	stringToBuffer(buffer + 136,
	    [OFString stringWithFormat: @"%011" PRIo64 " ", modificationDate],
	    12);








>
>









|
>
|
















|
|
>
>
>







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

- (OFString *)description
{
	void *pool = objc_autoreleasePoolPush();
	OFString *ret = [OFString stringWithFormat: @"<%@:\n"
	     @"\tFile name = %@\n"
	     @"\tMode = %06o\n"
	     @"\tUID = %u\n",
	     @"\tGID = %u\n",
	     @"\tSize = %" PRIu64 @"\n"
	     @"\tModification date = %@\n"
	     @"\tType = %u\n"
	     @"\tTarget file name = %@\n"
	     @"\tOwner = %@\n"
	     @"\tGroup = %@\n"
	     @"\tDevice major = %" PRIu32 @"\n"
	     @"\tDevice minor = %" PRIu32 @"\n"
	     @">",
	    [self class], _fileName, _mode, _UID, _GID, _size,
	    _modificationDate, _type, _targetFileName, _owner, _group,
	    _deviceMajor, _deviceMinor];

	[ret retain];

	objc_autoreleasePoolPop(pool);

	return [ret autorelease];
}

- (void)of_writeToStream: (OFStream *)stream
{
	unsigned char buffer[512];
	uint64_t modificationDate;
	uint16_t checksum = 0;

	stringToBuffer(buffer, _fileName, 100);
	stringToBuffer(buffer + 100,
	    [OFString stringWithFormat: @"%06" PRIo16 " ", _mode], 8);
	stringToBuffer(buffer + 108,
	    [OFString stringWithFormat: @"%06" PRIo16 " ", _UID], 8);
	stringToBuffer(buffer + 116,
	    [OFString stringWithFormat: @"%06" PRIo16 " ", _GID], 8);
	stringToBuffer(buffer + 124,
	    [OFString stringWithFormat: @"%011" PRIo64 " ", _size], 12);
	modificationDate = [_modificationDate timeIntervalSince1970];
	stringToBuffer(buffer + 136,
	    [OFString stringWithFormat: @"%011" PRIo64 " ", modificationDate],
	    12);

Modified utils/ofzip/TarArchive.m from [ea98a01b6f] to [b76a2b83a9].

89
90
91
92
93
94
95




96
97
98
99
100
101
102
103
104








105
106
107
108
109
110
111
		if (app->_outputLevel >= 1) {
			OFString *date = [[entry modificationDate]
			    localDateStringWithFormat: @"%Y-%m-%d %H:%M:%S"];
			OFString *size = [OFString stringWithFormat:
			    @"%" PRIu64, [entry size]];
			OFString *mode = [OFString stringWithFormat:
			    @"%06o", [entry mode]];





			[of_stdout writeString: @"\t"];
			[of_stdout writeLine: OF_LOCALIZED(@"list_size",
			    @"Size: %[size] bytes",
			    @"size", size)];
			[of_stdout writeString: @"\t"];
			[of_stdout writeLine: OF_LOCALIZED(@"list_mode",
			    @"Mode: %[mode]",
			    @"mode", mode)];









			if ([entry owner] != nil) {
				[of_stdout writeString: @"\t"];
				[of_stdout writeLine: OF_LOCALIZED(
				    @"list_owner",
				    @"Owner: %[owner]",
				    @"owner", [entry owner])];







>
>
>
>









>
>
>
>
>
>
>
>







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
121
122
123
		if (app->_outputLevel >= 1) {
			OFString *date = [[entry modificationDate]
			    localDateStringWithFormat: @"%Y-%m-%d %H:%M:%S"];
			OFString *size = [OFString stringWithFormat:
			    @"%" PRIu64, [entry size]];
			OFString *mode = [OFString stringWithFormat:
			    @"%06o", [entry mode]];
			OFString *UID = [OFString stringWithFormat:
			    @"%u", [entry UID]];
			OFString *GID = [OFString stringWithFormat:
			    @"%u", [entry GID]];

			[of_stdout writeString: @"\t"];
			[of_stdout writeLine: OF_LOCALIZED(@"list_size",
			    @"Size: %[size] bytes",
			    @"size", size)];
			[of_stdout writeString: @"\t"];
			[of_stdout writeLine: OF_LOCALIZED(@"list_mode",
			    @"Mode: %[mode]",
			    @"mode", mode)];
			[of_stdout writeString: @"\t"];
			[of_stdout writeLine: OF_LOCALIZED(@"list_uid",
			    @"UID: %[uid]",
			    @"uid", UID)];
			[of_stdout writeString: @"\t"];
			[of_stdout writeLine: OF_LOCALIZED(@"list_gid",
			    @"GID: %[gid]",
			    @"gid", GID)];

			if ([entry owner] != nil) {
				[of_stdout writeString: @"\t"];
				[of_stdout writeLine: OF_LOCALIZED(
				    @"list_owner",
				    @"Owner: %[owner]",
				    @"owner", [entry owner])];