320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
|
#ifdef OF_HAVE_SANDBOX
if (![remainingArguments.firstObject isEqual: @"-"])
[sandbox unveilPath: remainingArguments.firstObject
permissions: (mode == 'a' ? @"rwc" : @"wc")];
for (OFString *path in files)
[sandbox unveilPath: path
permissions: @"r"];
sandbox.allowsUnveil = false;
[OFApplication activateSandbox: sandbox];
#endif
archive = [self
openArchiveWithPath: remainingArguments.firstObject
|
|
<
|
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
|
#ifdef OF_HAVE_SANDBOX
if (![remainingArguments.firstObject isEqual: @"-"])
[sandbox unveilPath: remainingArguments.firstObject
permissions: (mode == 'a' ? @"rwc" : @"wc")];
for (OFString *path in files)
[sandbox unveilPath: path permissions: @"r"];
sandbox.allowsUnveil = false;
[OFApplication activateSandbox: sandbox];
#endif
archive = [self
openArchiveWithPath: remainingArguments.firstObject
|
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
|
#ifdef OF_HAVE_SANDBOX
if (![remainingArguments.firstObject isEqual: @"-"])
[sandbox unveilPath: remainingArguments.firstObject
permissions: @"r"];
if (files.count > 0)
for (OFString *path in files)
[sandbox unveilPath: path
permissions: @"wc"];
else {
OFString *path = (outputDir != nil
? outputDir : OF_PATH_CURRENT_DIRECTORY);
/* We need 'r' to change the directory to it. */
[sandbox unveilPath: path
permissions: @"rwc"];
}
sandbox.allowsUnveil = false;
[OFApplication activateSandbox: sandbox];
#endif
archive = [self
|
|
<
|
<
|
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
|
#ifdef OF_HAVE_SANDBOX
if (![remainingArguments.firstObject isEqual: @"-"])
[sandbox unveilPath: remainingArguments.firstObject
permissions: @"r"];
if (files.count > 0)
for (OFString *path in files)
[sandbox unveilPath: path permissions: @"wc"];
else {
OFString *path = (outputDir != nil
? outputDir : OF_PATH_CURRENT_DIRECTORY);
/* We need 'r' to change the directory to it. */
[sandbox unveilPath: path permissions: @"rwc"];
}
sandbox.allowsUnveil = false;
[OFApplication activateSandbox: sandbox];
#endif
archive = [self
|
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
|
file = of_stdin;
break;
default:
@throw [OFInvalidArgumentException exception];
}
} else {
@try {
file = [OFFile fileWithPath: path
mode: fileModeString];
} @catch (OFOpenItemFailedException *e) {
OFString *error = [OFString
stringWithCString: strerror(e.errNo)
encoding: [OFLocale encoding]];
[of_stderr writeString: @"\r"];
[of_stderr writeLine: OF_LOCALIZED(
@"failed_to_open_file",
|
|
<
|
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
|
file = of_stdin;
break;
default:
@throw [OFInvalidArgumentException exception];
}
} else {
@try {
file = [OFFile fileWithPath: path mode: fileModeString];
} @catch (OFOpenItemFailedException *e) {
OFString *error = [OFString
stringWithCString: strerror(e.errNo)
encoding: [OFLocale encoding]];
[of_stderr writeString: @"\r"];
[of_stderr writeLine: OF_LOCALIZED(
@"failed_to_open_file",
|
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
|
toStream: (OFStream *)output
fileName: (OFString *)fileName
{
char buffer[BUFFER_SIZE];
size_t length;
@try {
length = [input readIntoBuffer: buffer
length: BUFFER_SIZE];
} @catch (OFReadFailedException *e) {
OFString *error = [OFString
stringWithCString: strerror(e.errNo)
encoding: [OFLocale encoding]];
[of_stdout writeString: @"\r"];
[of_stderr writeLine: OF_LOCALIZED(@"failed_to_read_file",
@"Failed to read file %[file]: %[error]",
@"file", fileName,
@"error", error)];
return -1;
}
@try {
[output writeBuffer: buffer
length: length];
} @catch (OFWriteFailedException *e) {
OFString *error = [OFString
stringWithCString: strerror(e.errNo)
encoding: [OFLocale encoding]];
[of_stdout writeString: @"\r"];
[of_stderr writeLine: OF_LOCALIZED(@"failed_to_write_file",
@"Failed to write file %[file]: %[error]",
|
|
<
|
<
|
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
|
toStream: (OFStream *)output
fileName: (OFString *)fileName
{
char buffer[BUFFER_SIZE];
size_t length;
@try {
length = [input readIntoBuffer: buffer length: BUFFER_SIZE];
} @catch (OFReadFailedException *e) {
OFString *error = [OFString
stringWithCString: strerror(e.errNo)
encoding: [OFLocale encoding]];
[of_stdout writeString: @"\r"];
[of_stderr writeLine: OF_LOCALIZED(@"failed_to_read_file",
@"Failed to read file %[file]: %[error]",
@"file", fileName,
@"error", error)];
return -1;
}
@try {
[output writeBuffer: buffer length: length];
} @catch (OFWriteFailedException *e) {
OFString *error = [OFString
stringWithCString: strerror(e.errNo)
encoding: [OFLocale encoding]];
[of_stdout writeString: @"\r"];
[of_stderr writeLine: OF_LOCALIZED(@"failed_to_write_file",
@"Failed to write file %[file]: %[error]",
|