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
89
90
91
92
93
|
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
89
90
91
92
93
94
95
96
|
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
-
+
+
-
-
+
+
+
|
[stream writeFormat:
@"Usage: %@ -[fhlnqvx] archive.zip [file1 file2 ...]\n",
[OFApplication programName]];
if (full)
[stream writeString:
@"\nOptions:\n"
@" -f Force / override files\n"
@" -h Show this help\n"
@" -l List all files in the archive\n"
@" -n Never override files\n"
@" -q Quiet mode (no output, except errors)\n"
@" -v Verbose output for file list\n"
@" -x Extract files\n"];
@" -f --force Force / override files\n"
@" -h --help Show this help\n"
@" -l --list List all files in the archive\n"
@" -n --no-clober Never override files\n"
@" -q --quiet Quiet mode (no output, except "
@"errors)\n"
@" -v --verbose Verbose output for file list\n"
@" -x --extract Extract files\n"];
[OFApplication terminateWithStatus: status];
}
static void
mutuallyExclusiveError(of_unichar_t option1, of_unichar_t option2)
mutuallyExclusiveError(of_unichar_t shortOption1, OFString *longOption1,
of_unichar_t shortOption2, OFString *longOption2)
{
[of_stderr writeFormat: @"Error: -%C and -%C are mutually exclusive!\n",
option1, option2];
[of_stderr writeFormat:
@"Error: -%C / --%@ and -%C / --%@ are mutually exclusive!\n",
shortOption1, longOption1, shortOption2, longOption2];
[OFApplication terminateWithStatus: 1];
}
static void
setPermissions(OFString *path, OFZIPArchiveEntry *entry)
{
#ifdef OF_HAVE_CHMOD
|
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
|
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
171
|
-
+
+
-
+
+
-
+
+
-
+
+
-
+
+
|
OFArray OF_GENERIC(OFString*) *remainingArguments, *files;
OFZIPArchive *archive;
while ((option = [optionsParser nextOption]) != '\0') {
switch (option) {
case 'f':
if (_override < 0)
mutuallyExclusiveError('f', 'n');
mutuallyExclusiveError(
'f', @"force", 'n', @"no-clobber");
_override = 1;
break;
case 'n':
if (_override > 0)
mutuallyExclusiveError('f', 'n');
mutuallyExclusiveError(
'f', @"force", 'n', @"no-clobber");
_override = -1;
break;
case 'v':
if (_outputLevel < 0)
mutuallyExclusiveError('v', 'q');
mutuallyExclusiveError(
'q', @"quiet", 'v', @"verbose");
_outputLevel++;
break;
case 'q':
if (_outputLevel > 0)
mutuallyExclusiveError('v', 'q');
mutuallyExclusiveError(
'q', @"quiet", 'v', @"verbose");
_outputLevel--;
break;
case 'l':
case 'x':
if (mode != '\0')
mutuallyExclusiveError('x', 'l');
mutuallyExclusiveError(
'l', @"list", 'x', @"extract");
mode = option;
break;
case 'h':
help(of_stdout, true, 0);
break;
case '=':
|