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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
|
withString: @"\n\t"];
}
static void
setPermissions(OFString *path, OFLHAArchiveEntry *entry)
{
#ifdef OF_FILE_MANAGER_SUPPORTS_PERMISSIONS
OFNumber *mode = entry.mode;
if (mode == nil)
return;
mode = [OFNumber numberWithUnsignedShort:
mode.unsignedShortValue & 0777];
OFFileAttributes attributes = [OFDictionary
dictionaryWithObject: mode
forKey: OFFilePOSIXPermissions];
[[OFFileManager defaultManager] setAttributes: attributes
ofItemAtPath: path];
#endif
}
static void
setModificationDate(OFString *path, OFLHAArchiveEntry *entry)
{
OFDate *modificationDate = entry.modificationDate;
OFFileAttributes attributes;
if (modificationDate == nil) {
/*
* Fall back to the original date if we have no modification
* date, as the modification date is a UNIX extension.
*/
modificationDate = entry.date;
if (modificationDate == nil)
return;
}
attributes = [OFDictionary
dictionaryWithObject: modificationDate
forKey: OFFileModificationDate];
[[OFFileManager defaultManager] setAttributes: attributes
ofItemAtPath: path];
}
@implementation LHAArchive
+ (void)initialize
|
|
|
|
|
|
<
|
<
<
<
<
<
<
<
<
<
<
<
<
<
|
|
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
62
63
64
65
66
67
68
69
70
71
|
withString: @"\n\t"];
}
static void
setPermissions(OFString *path, OFLHAArchiveEntry *entry)
{
#ifdef OF_FILE_MANAGER_SUPPORTS_PERMISSIONS
OFNumber *POSIXPermissions = entry.POSIXPermissions;
if (POSIXPermissions == nil)
return;
POSIXPermissions = [OFNumber numberWithUnsignedShort:
POSIXPermissions.unsignedShortValue & 0777];
OFFileAttributes attributes = [OFDictionary
dictionaryWithObject: POSIXPermissions
forKey: OFFilePOSIXPermissions];
[[OFFileManager defaultManager] setAttributes: attributes
ofItemAtPath: path];
#endif
}
static void
setModificationDate(OFString *path, OFLHAArchiveEntry *entry)
{
OFFileAttributes attributes = [OFDictionary
dictionaryWithObject: entry.modificationDate
forKey: OFFileModificationDate];
[[OFFileManager defaultManager] setAttributes: attributes
ofItemAtPath: path];
}
@implementation LHAArchive
+ (void)initialize
|
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
|
while ((entry = [_archive nextEntry]) != nil) {
void *pool = objc_autoreleasePoolPush();
[OFStdOut writeLine: entry.fileName];
if (app->_outputLevel >= 1) {
OFString *date = [entry.date
localDateStringWithFormat: @"%Y-%m-%d %H:%M:%S"];
OFString *compressedSize = [OFString stringWithFormat:
@"%" PRIu32, entry.compressedSize];
OFString *uncompressedSize = [OFString stringWithFormat:
@"%" PRIu32, entry.uncompressedSize];
OFString *CRC16 = [OFString stringWithFormat:
@"%04" PRIX16, entry.CRC16];
[OFStdOut writeString: @"\t"];
[OFStdOut writeLine: OF_LOCALIZED(
@"list_compressed_size",
@"["
|
|
|
|
|
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
|
while ((entry = [_archive nextEntry]) != nil) {
void *pool = objc_autoreleasePoolPush();
[OFStdOut writeLine: entry.fileName];
if (app->_outputLevel >= 1) {
OFString *modificationDate = [entry.modificationDate
localDateStringWithFormat: @"%Y-%m-%d %H:%M:%S"];
OFString *compressedSize = [OFString stringWithFormat:
@"%llu", entry.compressedSize];
OFString *uncompressedSize = [OFString stringWithFormat:
@"%llu", entry.uncompressedSize];
OFString *CRC16 = [OFString stringWithFormat:
@"%04" PRIX16, entry.CRC16];
[OFStdOut writeString: @"\t"];
[OFStdOut writeLine: OF_LOCALIZED(
@"list_compressed_size",
@"["
|
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
221
222
223
|
@"Compression method: %[method]",
@"method", entry.compressionMethod)];
[OFStdOut writeString: @"\t"];
[OFStdOut writeLine: OF_LOCALIZED(@"list_crc16",
@"CRC16: %[crc16]",
@"crc16", CRC16)];
[OFStdOut writeString: @"\t"];
[OFStdOut writeLine: OF_LOCALIZED(@"list_date",
@"Date: %[date]",
@"date", date)];
if (entry.mode != nil) {
OFString *modeString = [OFString
stringWithFormat:
@"%ho", entry.mode.unsignedShortValue];
[OFStdOut writeString: @"\t"];
[OFStdOut writeLine: OF_LOCALIZED(@"list_mode",
@"Mode: %[mode]",
@"mode", modeString)];
}
if (entry.UID != nil) {
[OFStdOut writeString: @"\t"];
[OFStdOut writeLine: OF_LOCALIZED(@"list_uid",
@"UID: %[uid]",
@"uid", entry.UID)];
}
if (entry.GID != nil) {
[OFStdOut writeString: @"\t"];
[OFStdOut writeLine: OF_LOCALIZED(@"list_gid",
@"GID: %[gid]",
@"gid", entry.GID)];
}
if (entry.owner != nil) {
[OFStdOut writeString: @"\t"];
[OFStdOut writeLine: OF_LOCALIZED(
@"list_owner",
@"Owner: %[owner]",
@"owner", entry.owner)];
}
if (entry.group != nil) {
[OFStdOut writeString: @"\t"];
[OFStdOut writeLine: OF_LOCALIZED(
@"list_group",
@"Group: %[group]",
@"group", entry.group)];
}
if (app->_outputLevel >= 2) {
OFString *headerLevel = [OFString
stringWithFormat: @"%" PRIu8,
entry.headerLevel];
|
|
>
|
|
|
|
|
>
|
|
>
|
|
|
|
>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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
|
@"Compression method: %[method]",
@"method", entry.compressionMethod)];
[OFStdOut writeString: @"\t"];
[OFStdOut writeLine: OF_LOCALIZED(@"list_crc16",
@"CRC16: %[crc16]",
@"crc16", CRC16)];
[OFStdOut writeString: @"\t"];
[OFStdOut writeLine: OF_LOCALIZED(
@"list_modification_date",
@"Modification date: %[date]",
@"date", modificationDate)];
if (entry.POSIXPermissions != nil) {
OFString *permissionsString = [OFString
stringWithFormat: @"%llo",
entry.POSIXPermissions
.unsignedLongLongValue];
[OFStdOut writeString: @"\t"];
[OFStdOut writeLine: OF_LOCALIZED(
@"list_posix_permissions",
@"POSIX permissions: %[perm]",
@"perm", permissionsString)];
}
if (entry.ownerAccountID != nil) {
[OFStdOut writeString: @"\t"];
[OFStdOut writeLine: OF_LOCALIZED(
@"list_owner_account_id",
@"Owner account ID: %[id]",
@"id", entry.ownerAccountID)];
}
if (entry.groupOwnerAccountID != nil) {
[OFStdOut writeString: @"\t"];
[OFStdOut writeLine: OF_LOCALIZED(@"list_gid",
@"Group owner account ID: %[id]",
@"id", entry.groupOwnerAccountID)];
}
if (entry.ownerAccountName != nil) {
[OFStdOut writeString: @"\t"];
[OFStdOut writeLine: OF_LOCALIZED(
@"list_owner_account_name",
@"Owner account name: %[name]",
@"name", entry.ownerAccountName)];
}
if (entry.groupOwnerAccountName != nil) {
[OFStdOut writeString: @"\t"];
[OFStdOut writeLine: OF_LOCALIZED(
@"list_group_owner_account_name",
@"Group: %[name]",
@"name", entry.groupOwnerAccountName)];
}
if (app->_outputLevel >= 2) {
OFString *headerLevel = [OFString
stringWithFormat: @"%" PRIu8,
entry.headerLevel];
|
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
|
[OFStdOut writeString: @"\t"];
[OFStdOut writeLine: OF_LOCALIZED(
@"list_osid",
@"Operating system identifier: "
"%[osid]",
@"osid", OSID)];
}
if (entry.modificationDate != nil) {
OFString *modificationDate =
entry.modificationDate.description;
[OFStdOut writeString: @"\t"];
[OFStdOut writeLine: OF_LOCALIZED(
@"list_modification_date",
@"Modification date: %[date]",
@"date", modificationDate)];
}
}
if (app->_outputLevel >= 3) {
OFString *extensions =
indent(entry.extensions.description);
[OFStdOut writeString: @"\t"];
|
<
<
<
<
<
<
<
<
<
<
<
|
225
226
227
228
229
230
231
232
233
234
235
236
237
238
|
[OFStdOut writeString: @"\t"];
[OFStdOut writeLine: OF_LOCALIZED(
@"list_osid",
@"Operating system identifier: "
"%[osid]",
@"osid", OSID)];
}
}
if (app->_outputLevel >= 3) {
OFString *extensions =
indent(entry.extensions.description);
[OFStdOut writeString: @"\t"];
|
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
|
while ((entry = [_archive nextEntry]) != nil) {
void *pool = objc_autoreleasePoolPush();
OFString *fileName = entry.fileName;
OFString *outFileName, *directory;
OFFile *output;
OFStream *stream;
uint64_t written = 0, size = entry.uncompressedSize;
int8_t percent = -1, newPercent;
if (!all && ![files containsObject: fileName])
continue;
[missing removeObject: fileName];
|
|
|
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
|
while ((entry = [_archive nextEntry]) != nil) {
void *pool = objc_autoreleasePoolPush();
OFString *fileName = entry.fileName;
OFString *outFileName, *directory;
OFFile *output;
OFStream *stream;
unsigned long long written = 0, size = entry.uncompressedSize;
int8_t percent = -1, newPercent;
if (!all && ![files containsObject: fileName])
continue;
[missing removeObject: fileName];
|
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
|
@"file", fileName)];
attributes = [fileManager attributesOfItemAtPath: fileName];
type = attributes.fileType;
entry = [OFMutableLHAArchiveEntry entryWithFileName: fileName];
#ifdef OF_FILE_MANAGER_SUPPORTS_PERMISSIONS
entry.mode = [OFNumber numberWithUnsignedLong:
attributes.filePOSIXPermissions];
#endif
entry.date = attributes.fileModificationDate;
#ifdef OF_FILE_MANAGER_SUPPORTS_OWNER
entry.UID = [OFNumber numberWithUnsignedLong:
attributes.fileOwnerAccountID];
entry.GID = [OFNumber numberWithUnsignedLong:
attributes.fileGroupOwnerAccountID];
entry.owner = attributes.fileOwnerAccountName;
entry.group = attributes.fileGroupOwnerAccountName;
#endif
if ([type isEqual: OFFileTypeDirectory]) {
entry.compressionMethod = @"-lhd-";
if (![entry.fileName hasSuffix: @"/"])
entry.fileName = [entry.fileName
|
|
|
|
|
|
|
|
|
>
|
>
|
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
|
@"file", fileName)];
attributes = [fileManager attributesOfItemAtPath: fileName];
type = attributes.fileType;
entry = [OFMutableLHAArchiveEntry entryWithFileName: fileName];
#ifdef OF_FILE_MANAGER_SUPPORTS_PERMISSIONS
entry.POSIXPermissions =
[attributes objectForKey: OFFilePOSIXPermissions];
#endif
entry.modificationDate = attributes.fileModificationDate;
#ifdef OF_FILE_MANAGER_SUPPORTS_OWNER
entry.ownerAccountID =
[attributes objectForKey: OFFileOwnerAccountID];
entry.groupOwnerAccountID =
[attributes objectForKey: OFFileGroupOwnerAccountID];
entry.ownerAccountName =
[attributes objectForKey: OFFileOwnerAccountName];
entry.groupOwnerAccountName =
[attributes objectForKey: OFFileGroupOwnerAccountName];
#endif
if ([type isEqual: OFFileTypeDirectory]) {
entry.compressionMethod = @"-lhd-";
if (![entry.fileName hasSuffix: @"/"])
entry.fileName = [entry.fileName
|