ObjFW  Check-in [e57ecc4311]

Overview
Comment:ofarc: Add support for adding files recursively
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: e57ecc4311987000fff29c59a688f17b07e9107ef80180230b7d6413ce61148b
User & Date: js on 2021-07-04 11:54:15
Other Links: manifest | tags
Context
2021-07-04
16:19
ofarc: Fix creating LHA files with directories check-in: d6bb16aa3b user: js tags: trunk
11:54
ofarc: Add support for adding files recursively check-in: e57ecc4311 user: js tags: trunk
2021-07-03
13:56
Add -[OFFileManager subpathsOfDirectoryAtPath:] check-in: 6985da09c8 user: js tags: trunk
Changes

Modified utils/ofarc/OFArc.m from [84fac1d63f] to [d48722ca04].

140
141
142
143
144
145
146

















147
148
149
150
151
152
153
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







+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+







writingNotSupported(OFString *type)
{
	[OFStdErr writeLine: OF_LOCALIZED(
	    @"writing_not_supported",
	    @"Writing archives of type %[type] is not (yet) supported!",
	    @"type", type)];
}

static void
addFiles(id <Archive> archive, OFArray OF_GENERIC(OFString *) *files)
{
	OFMutableArray *expandedFiles =
	    [OFMutableArray arrayWithCapacity: files.count];
	OFFileManager *fileManager = [OFFileManager defaultManager];

	for (OFString *file in files)
		if ([fileManager directoryExistsAtPath: file])
			[expandedFiles addObjectsFromArray: 
			    [fileManager subpathsOfDirectoryAtPath: file]];
		else
			[expandedFiles addObject: file];

	[archive addFiles: expandedFiles];
}

@implementation OFArc
- (void)applicationDidFinishLaunching
{
	OFString *outputDir, *encodingString, *type;
	const OFOptionsParserOption options[] = {
		{ 'a', @"append", 0, NULL, NULL },
332
333
334
335
336
337
338
339

340
341
342
343
344
345
346
349
350
351
352
353
354
355

356
357
358
359
360
361
362
363







-
+








		archive = [self
		    openArchiveWithPath: remainingArguments.firstObject
				   type: type
				   mode: mode
			       encoding: encoding];

		[archive addFiles: files];
		addFiles(archive, files);
		break;
	case 'l':
		if (remainingArguments.count != 1)
			help(OFStdErr, false, 1);

#ifdef OF_HAVE_SANDBOX
		if (![remainingArguments.firstObject isEqual: @"-"])