45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
[stream writeFormat:
@"Usage: %@ -[fhlnqvx] archive.zip [file1 file2 ...]\n",
[OFApplication programName]];
if (full)
[stream writeString:
@"\nOptions:\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];
}
|
|
|
|
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
[stream writeFormat:
@"Usage: %@ -[fhlnqvx] archive.zip [file1 file2 ...]\n",
[OFApplication programName]];
if (full)
[stream writeString:
@"\nOptions:\n"
@" -f --force Force / overwrite files\n"
@" -h --help Show this help\n"
@" -l --list List all files in the archive\n"
@" -n --no-clober Never overwrite 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];
}
|
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
|
of_unichar_t option, mode = '\0';
OFArray OF_GENERIC(OFString*) *remainingArguments, *files;
id <Archive> archive;
while ((option = [optionsParser nextOption]) != '\0') {
switch (option) {
case 'f':
if (_override < 0)
mutuallyExclusiveError(
'f', @"force", 'n', @"no-clobber");
_override = 1;
break;
case 'n':
if (_override > 0)
mutuallyExclusiveError(
'f', @"force", 'n', @"no-clobber");
_override = -1;
break;
case 'v':
if (_outputLevel < 0)
mutuallyExclusiveError(
'q', @"quiet", 'v', @"verbose");
_outputLevel++;
|
|
|
|
|
|
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
|
of_unichar_t option, mode = '\0';
OFArray OF_GENERIC(OFString*) *remainingArguments, *files;
id <Archive> archive;
while ((option = [optionsParser nextOption]) != '\0') {
switch (option) {
case 'f':
if (_overwrite < 0)
mutuallyExclusiveError(
'f', @"force", 'n', @"no-clobber");
_overwrite = 1;
break;
case 'n':
if (_overwrite > 0)
mutuallyExclusiveError(
'f', @"force", 'n', @"no-clobber");
_overwrite = -1;
break;
case 'v':
if (_outputLevel < 0)
mutuallyExclusiveError(
'q', @"quiet", 'v', @"verbose");
_outputLevel++;
|
231
232
233
234
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
260
261
262
263
264
265
266
267
268
269
270
271
272
|
}
- (bool)shouldExtractFile: (OFString*)fileName
outFileName: (OFString*)outFileName
{
OFString *line;
if (_override == 1 ||
![[OFFileManager defaultManager] fileExistsAtPath: outFileName])
return true;
if (_override == -1) {
if (_outputLevel >= 0)
[of_stdout writeLine: @" skipped"];
return false;
}
do {
[of_stderr writeFormat: @"\rOverride %@? [ynAN?] ", fileName];
line = [of_stdin readLine];
if ([line isEqual: @"?"])
[of_stderr writeString: @" y: yes\n"
@" n: no\n"
@" A: always\n"
@" N: never\n"];
} while (![line isEqual: @"y"] && ![line isEqual: @"n"] &&
![line isEqual: @"N"] && ![line isEqual: @"A"]);
if ([line isEqual: @"A"])
_override = 1;
else if ([line isEqual: @"N"])
_override = -1;
if ([line isEqual: @"n"] || [line isEqual: @"N"]) {
if (_outputLevel >= 0)
[of_stdout writeFormat: @"Skipping %@...\n", fileName];
return false;
}
|
|
|
|
|
|
|
231
232
233
234
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
260
261
262
263
264
265
266
267
268
269
270
271
272
|
}
- (bool)shouldExtractFile: (OFString*)fileName
outFileName: (OFString*)outFileName
{
OFString *line;
if (_overwrite == 1 ||
![[OFFileManager defaultManager] fileExistsAtPath: outFileName])
return true;
if (_overwrite == -1) {
if (_outputLevel >= 0)
[of_stdout writeLine: @" skipped"];
return false;
}
do {
[of_stderr writeFormat: @"\rOverwrite %@? [ynAN?] ", fileName];
line = [of_stdin readLine];
if ([line isEqual: @"?"])
[of_stderr writeString: @" y: yes\n"
@" n: no\n"
@" A: always\n"
@" N: never\n"];
} while (![line isEqual: @"y"] && ![line isEqual: @"n"] &&
![line isEqual: @"N"] && ![line isEqual: @"A"]);
if ([line isEqual: @"A"])
_overwrite = 1;
else if ([line isEqual: @"N"])
_overwrite = -1;
if ([line isEqual: @"n"] || [line isEqual: @"N"]) {
if (_outputLevel >= 0)
[of_stdout writeFormat: @"Skipping %@...\n", fileName];
return false;
}
|