ObjFW  Diff

Differences From Artifact [9ff77cb7ca]:

  • File utils/ofarc/OFArc.m — part of check-in [6cb8bad11d] at 2025-04-28 21:04:01 on branch trunk — utils: Add build date to $VER string (user: js size: 23867) [more...]

To Artifact [0eb1163569]:

  • File utils/ofarc/OFArc.m — part of check-in [3a5f609bae] at 2025-05-02 21:54:34 on branch trunk — Add --version to all utils (user: js size: 24520)

27
28
29
30
31
32
33

34
35
36
37
38
39
40
#import "OFFileManager.h"
#import "OFIRI.h"
#import "OFIRIHandler.h"
#import "OFLocale.h"
#import "OFOptionsParser.h"
#import "OFSandbox.h"
#import "OFStdIOStream.h"


#import "OFArc.h"
#import "GZIPArchive.h"
#import "LHAArchive.h"
#import "TarArchive.h"
#import "ZIPArchive.h"
#import "ZooArchive.h"







>







27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#import "OFFileManager.h"
#import "OFIRI.h"
#import "OFIRIHandler.h"
#import "OFLocale.h"
#import "OFOptionsParser.h"
#import "OFSandbox.h"
#import "OFStdIOStream.h"
#import "OFSystemInfo.h"

#import "OFArc.h"
#import "GZIPArchive.h"
#import "LHAArchive.h"
#import "TarArchive.h"
#import "ZIPArchive.h"
#import "ZooArchive.h"
104
105
106
107
108
109
110
111


112
113
114
115














116
117
118
119
120
121
122
		    @"the archive\n"
		    @"    -q  --quiet             Quiet mode (no output, "
		    @"except errors)\n"
		    @"    -t  --type=             Archive type (gz, lha, tar, "
		    @"tgz, zip, zoo)\n"
		    @"    -v  --verbose           Verbose output for file list"
		    @"\n"
		    @"    -x  --extract           Extract files")];


	}

	[OFApplication terminateWithStatus: status];
}















static void
mutuallyExclusiveError(OFUnichar shortOption1, OFString *longOption1,
    OFUnichar shortOption2, OFString *longOption2)
{
	OFString *shortOption1Str = [OFString stringWithFormat: @"%C",
								shortOption1];







|
>
>




>
>
>
>
>
>
>
>
>
>
>
>
>
>







105
106
107
108
109
110
111
112
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
		    @"the archive\n"
		    @"    -q  --quiet             Quiet mode (no output, "
		    @"except errors)\n"
		    @"    -t  --type=             Archive type (gz, lha, tar, "
		    @"tgz, zip, zoo)\n"
		    @"    -v  --verbose           Verbose output for file list"
		    @"\n"
		    @"    -x  --extract           Extract files\n"
		    @"        --version           Print the version "
		    @"information")];
	}

	[OFApplication terminateWithStatus: status];
}

static void
version(void)
{
	[OFStdOut writeFormat: @"ofarc %@ (ObjFW %@) "
			       @"<https://objfw.nil.im/>\n"
	    		       @"Copyright (c) 2008-2025 Jonathan Schleifer "
			       @"<js@nil.im>\n"
			       @"Licensed under the LGPL 3.0 "
			       @"<https://www.gnu.org/licenses/lgpl-3.0.html>"
			       @"\n",
			       @PACKAGE_VERSION, [OFSystemInfo ObjFWVersion]];
	[OFApplication terminate];
}

static void
mutuallyExclusiveError(OFUnichar shortOption1, OFString *longOption1,
    OFUnichar shortOption2, OFString *longOption2)
{
	OFString *shortOption1Str = [OFString stringWithFormat: @"%C",
								shortOption1];
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242

243
244
245
246
247
248
249

@implementation OFArc
- (void)applicationDidFinishLaunching: (OFNotification *)notification
{
	OFString *archiveComment, *outputDir, *encodingString, *type;
	bool isIRI;
	const OFOptionsParserOption options[] = {
		{ 'a', @"append", 0, NULL, NULL },
		{ 0,   @"archive-comment", 1, NULL, &archiveComment },
		{ 'c', @"create", 0, NULL, NULL },
		{ 'C', @"directory", 1, NULL, &outputDir },
		{ 'E', @"encoding", 1, NULL, &encodingString },
		{ 'f', @"force", 0, NULL, NULL },
		{ 'h', @"help", 0, NULL, NULL },
		{ 0,   @"iri", 0, &isIRI, NULL },
		{ 'l', @"list", 0, NULL, NULL },
		{ 'n', @"no-clobber", 0, NULL, NULL },
		{ 'p', @"print", 0, NULL, NULL },
		{ 'q', @"quiet", 0, NULL, NULL },
		{ 't', @"type", 1, NULL, &type },
		{ 'v', @"verbose", 0, NULL, NULL },
		{ 'x', @"extract", 0, NULL, NULL },

		{ '\0', nil, 0, NULL, NULL }
	};
	OFUnichar option, mode = '\0';
	OFStringEncoding encoding = OFStringEncodingAutodetect;
	OFOptionsParser *optionsParser;
	OFArray OF_GENERIC(OFString *) *remainingArguments, *files;
	OFIRI *IRI;







|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
>







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

@implementation OFArc
- (void)applicationDidFinishLaunching: (OFNotification *)notification
{
	OFString *archiveComment, *outputDir, *encodingString, *type;
	bool isIRI;
	const OFOptionsParserOption options[] = {
		{ 'a',  @"append", 0, NULL, NULL },
		{ '\0', @"archive-comment", 1, NULL, &archiveComment },
		{ 'c',  @"create", 0, NULL, NULL },
		{ 'C',  @"directory", 1, NULL, &outputDir },
		{ 'E',  @"encoding", 1, NULL, &encodingString },
		{ 'f',  @"force", 0, NULL, NULL },
		{ 'h',  @"help", 0, NULL, NULL },
		{ '\0', @"iri", 0, &isIRI, NULL },
		{ 'l',  @"list", 0, NULL, NULL },
		{ 'n',  @"no-clobber", 0, NULL, NULL },
		{ 'p',  @"print", 0, NULL, NULL },
		{ 'q',  @"quiet", 0, NULL, NULL },
		{ 't',  @"type", 1, NULL, &type },
		{ 'v',  @"verbose", 0, NULL, NULL },
		{ 'x',  @"extract", 0, NULL, NULL },
		{ '\0', @"version", 0, NULL, NULL },
		{ '\0', nil, 0, NULL, NULL }
	};
	OFUnichar option, mode = '\0';
	OFStringEncoding encoding = OFStringEncodingAutodetect;
	OFOptionsParser *optionsParser;
	OFArray OF_GENERIC(OFString *) *remainingArguments, *files;
	OFIRI *IRI;
316
317
318
319
320
321
322



323
324
325
326
327
328
329
				    'x', @"extract");

			mode = option;
			break;
		case 'h':
			help(OFStdOut, true, 0);
			break;



		case '=':
			[OFStdErr writeLine: OF_LOCALIZED(
			    @"option_takes_no_argument",
			    @"%[prog]: Option --%[opt] takes no argument",
			    @"prog", [OFApplication programName],
			    @"opt", optionsParser.lastLongOption)];








>
>
>







334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
				    'x', @"extract");

			mode = option;
			break;
		case 'h':
			help(OFStdOut, true, 0);
			break;
		case '-':
			if ([optionsParser.lastLongOption isEqual: @"version"])
				version();
		case '=':
			[OFStdErr writeLine: OF_LOCALIZED(
			    @"option_takes_no_argument",
			    @"%[prog]: Option --%[opt] takes no argument",
			    @"prog", [OFApplication programName],
			    @"opt", optionsParser.lastLongOption)];