ObjFW  Diff

Differences From Artifact [e32d96f125]:

To Artifact [1feea72626]:


29
30
31
32
33
34
35
36
37


38
39

40
41
42
43
44
45
46
29
30
31
32
33
34
35


36
37
38

39
40
41
42
43
44
45
46







-
-
+
+

-
+








static OFArc *app;

static void
setPermissions(OFString *path, OFTarArchiveEntry *entry)
{
#ifdef OF_FILE_MANAGER_SUPPORTS_PERMISSIONS
	OFNumber *mode = [OFNumber numberWithUnsignedLongLong:
	    entry.mode.longLongValue & 0777];
	OFNumber *POSIXPermissions = [OFNumber numberWithUnsignedLongLong:
	    entry.POSIXPermissions.longLongValue & 0777];
	OFFileAttributes attributes = [OFDictionary
	    dictionaryWithObject: mode
	    dictionaryWithObject: POSIXPermissions
			  forKey: OFFilePOSIXPermissions];

	[[OFFileManager defaultManager] setAttributes: attributes
					 ofItemAtPath: path];
#endif
}

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







+
-
-
+
+
+
-
-












-
-
+
+
+
-
+

-
-
-
+
+
+
+

-
-
-
+
+
+
+

-
+


-
-
-
+
+
+

-
+


-
-
-
+
+
+







		[OFStdOut writeLine: entry.fileName];

		if (app->_outputLevel >= 1) {
			OFString *date = [entry.modificationDate
			    localDateStringWithFormat: @"%Y-%m-%d %H:%M:%S"];
			OFString *size = [OFString stringWithFormat:
			    @"%llu", entry.uncompressedSize];
			OFString *permissionsString = [OFString
			OFString *mode = [OFString stringWithFormat:
			    @"%06llo", entry.mode.unsignedLongLongValue];
			    stringWithFormat:
			    @"%llo", entry.POSIXPermissions
			    .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'},"
			    @"        {'': '%[size] bytes'}"
			    @"    ]"
			    @"]".objectByParsingJSON,
			    @"size", size)];
			[OFStdOut writeString: @"\t"];
			[OFStdOut writeLine: OF_LOCALIZED(@"list_mode",
			    @"Mode: %[mode]",
			[OFStdOut writeLine:
			    OF_LOCALIZED(@"list_posix_permissions",
			    @"POSIX permissions: %[perm]",
			    @"mode", mode)];
			    @"perm", permissionsString)];
			[OFStdOut writeString: @"\t"];
			[OFStdOut writeLine: OF_LOCALIZED(@"list_uid",
			    @"UID: %[uid]",
			    @"uid", UID)];
			[OFStdOut writeLine: OF_LOCALIZED(
			    @"list_owner_account_id",
			    @"Owner account ID: %[id]",
			    @"id", entry.ownerAccountID)];
			[OFStdOut writeString: @"\t"];
			[OFStdOut writeLine: OF_LOCALIZED(@"list_gid",
			    @"GID: %[gid]",
			    @"gid", GID)];
			[OFStdOut writeLine: OF_LOCALIZED(
			    @"list_group_owner_account_id",
			    @"Group owner account ID: %[id]",
			    @"id", entry.groupOwnerAccountID)];

			if (entry.owner != nil) {
			if (entry.ownerAccountName != nil) {
				[OFStdOut writeString: @"\t"];
				[OFStdOut writeLine: OF_LOCALIZED(
				    @"list_owner",
				    @"Owner: %[owner]",
				    @"owner", entry.owner)];
				    @"list_owner_account_name",
				    @"Owner account name: %[name]",
				    @"name", entry.ownerAccountName)];
			}
			if (entry.group != nil) {
			if (entry.groupOwnerAccountName != nil) {
				[OFStdOut writeString: @"\t"];
				[OFStdOut writeLine: OF_LOCALIZED(
				    @"list_group",
				    @"Group: %[group]",
				    @"group", entry.group)];
				    @"list_group_owner_account_name",
				    @"Group owner account name: %[name]",
				    @"name", entry.groupOwnerAccountName)];
			}

			[OFStdOut writeString: @"\t"];
			[OFStdOut writeLine: OF_LOCALIZED(
			    @"list_modification_date",
			    @"Modification date: %[date]",
			    @"date", date)];
474
475
476
477
478
479
480

481

482
483
484
485
486

487
488


489
490
491



492
493
494
495
496
497
498
477
478
479
480
481
482
483
484

485
486
487
488
489
490
491


492
493
494


495
496
497
498
499
500
501
502
503
504







+
-
+





+
-
-
+
+

-
-
+
+
+







			    @"file", fileName)];

		attributes = [fileManager attributesOfItemAtPath: fileName];
		type = attributes.fileType;
		entry = [OFMutableTarArchiveEntry entryWithFileName: fileName];

#ifdef OF_FILE_MANAGER_SUPPORTS_PERMISSIONS
		entry.POSIXPermissions =
		entry.mode = [attributes objectForKey: OFFilePOSIXPermissions];
		    [attributes objectForKey: OFFilePOSIXPermissions];
#endif
		entry.uncompressedSize = attributes.fileSize;
		entry.modificationDate = attributes.fileModificationDate;

#ifdef OF_FILE_MANAGER_SUPPORTS_OWNER
		entry.ownerAccountID =
		entry.UID = [attributes objectForKey: OFFileOwnerAccountID];
		entry.GID =
		    [attributes objectForKey: OFFileOwnerAccountID];
		entry.groupOwnerAccountID =
		    [attributes objectForKey: OFFileGroupOwnerAccountID];
		entry.owner = attributes.fileOwnerAccountName;
		entry.group = attributes.fileGroupOwnerAccountName;
		entry.ownerAccountName = attributes.fileOwnerAccountName;
		entry.groupOwnerAccountName =
		    attributes.fileGroupOwnerAccountName;
#endif

		if ([type isEqual: OFFileTypeRegular])
			entry.type = OFTarArchiveEntryTypeFile;
		else if ([type isEqual: OFFileTypeDirectory]) {
			entry.type = OFTarArchiveEntryTypeDirectory;
			entry.uncompressedSize = 0;