Index: utils/ofzip/OFZIP.m ================================================================== --- utils/ofzip/OFZIP.m +++ utils/ofzip/OFZIP.m @@ -137,11 +137,10 @@ { [of_stderr writeLine: OF_LOCALIZED( @"writing_not_supported", @"Writing archives of type %[type] is not (yet) supported!", @"type", type)]; - [OFApplication terminateWithStatus: 1]; } @implementation OFZIP - (void)applicationDidFinishLaunching { @@ -413,16 +412,19 @@ else { [of_stderr writeLine: OF_LOCALIZED( @"unknown_archive_type", @"Unknown archive type: %[type]", @"type", type)]; - [OFApplication terminateWithStatus: 1]; + goto error; } } @catch (OFNotImplementedException *e) { if ((mode == 'a' || mode == 'c') && - sel_isEqual([e selector], @selector(initWithStream:mode:))) + sel_isEqual([e selector], + @selector(initWithStream:mode:))) { writingNotSupported(type); + goto error; + } @throw e; } @catch (OFReadFailedException *e) { OFString *error = [OFString stringWithCString: strerror([e errNo]) @@ -429,33 +431,41 @@ encoding: [OFLocalization encoding]]; [of_stderr writeLine: OF_LOCALIZED(@"failed_to_read_file", @"Failed to read file %[file]: %[error]", @"file", path, @"error", error)]; - [OFApplication terminateWithStatus: 1]; + goto error; } @catch (OFSeekFailedException *e) { OFString *error = [OFString stringWithCString: strerror([e errNo]) encoding: [OFLocalization encoding]]; [of_stderr writeLine: OF_LOCALIZED(@"failed_to_seek_in_file", @"Failed to seek in file %[file]: %[error]", @"file", path, @"error", error)]; - [OFApplication terminateWithStatus: 1]; + goto error; } @catch (OFInvalidFormatException *e) { [of_stderr writeLine: OF_LOCALIZED( @"file_is_not_a_valid_archive", @"File %[file] is not a valid archive!", @"file", path)]; - [OFApplication terminateWithStatus: 1]; + goto error; } if ((mode == 'a' || mode == 'c') && - ![archive respondsToSelector: @selector(addFiles:)]) + ![archive respondsToSelector: @selector(addFiles:)]) { writingNotSupported(type); + goto error; + } return archive; + +error: + if (mode == 'c') + [[OFFileManager defaultManager] removeItemAtPath: path]; + + [OFApplication terminateWithStatus: 1]; } - (bool)shouldExtractFile: (OFString *)fileName outFileName: (OFString *)outFileName {