Index: utils/ofarc/Archive.h ================================================================== --- utils/ofarc/Archive.h +++ utils/ofarc/Archive.h @@ -33,9 +33,10 @@ encoding: (OFStringEncoding)encoding; - (void)listFiles; - (void)extractFiles: (OFArray OF_GENERIC(OFString *) *)files; - (void)printFiles: (OFArray OF_GENERIC(OFString *) *)files; @optional -- (void)addFiles: (OFArray OF_GENERIC(OFString *) *)files; +- (void)addFiles: (OFArray OF_GENERIC(OFString *) *)files + archiveComment: (nullable OFString *)archiveComment; @end OF_ASSUME_NONNULL_END Index: utils/ofarc/LHAArchive.m ================================================================== --- utils/ofarc/LHAArchive.m +++ utils/ofarc/LHAArchive.m @@ -445,20 +445,14 @@ app->_exitStatus = 1; } } - (void)addFiles: (OFArray OF_GENERIC(OFString *) *)files + archiveComment: (OFString *)archiveComment { OFFileManager *fileManager = [OFFileManager defaultManager]; - if (files.count < 1) { - [OFStdErr writeLine: OF_LOCALIZED(@"add_no_file_specified", - @"Need one or more files to add!")]; - app->_exitStatus = 1; - return; - } - for (OFString *fileName in files) { void *pool = objc_autoreleasePoolPush(); OFFileAttributes attributes; OFFileAttributeType type; OFMutableLHAArchiveEntry *entry; Index: utils/ofarc/OFArc.m ================================================================== --- utils/ofarc/OFArc.m +++ utils/ofarc/OFArc.m @@ -57,29 +57,36 @@ if (full) { [stream writeString: @"\n"]; [stream writeLine: OF_LOCALIZED(@"full_usage", @"Options:\n" - @" -a --append Append to archive\n" - @" -c --create Create archive\n" - @" -C --directory= Extract into the specified " + @" -a --append Append to archive\n" + @" --archive-comment= Archive comment to use when " + @"creating or appending\n" + @" -c --create Create archive\n" + @" -C --directory= Extract into the specified " @"directory\n" - @" -E --encoding= The encoding used by the archive\n" - @" (only tar, lha and zoo files)\n" - @" -f --force Force / overwrite files\n" - @" -h --help Show this help\n" - @" --iri Use an IRI to access the archive\n" - @" -l --list List all files in the archive\n" - @" -n --no-clobber Never overwrite files\n" - @" -p --print Print one or more files from the " + @" -E --encoding= The encoding used by the " + @"archive\n" + @" (only tar, lha and zoo files)" + @"\n" + @" -f --force Force / overwrite files\n" + @" -h --help Show this help\n" + @" --iri Use an IRI to access 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")]; + @" -l --list List all files in the archive" + @"\n" + @" -n --no-clobber Never overwrite files\n" + @" -p --print Print one or more files from " + @"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]; } @@ -159,11 +166,12 @@ @"Writing archives of type %[type] is not (yet) supported!", @"type", type)]; } static void -addFiles(id archive, OFArray OF_GENERIC(OFString *) *files) +addFiles(id archive, OFArray OF_GENERIC(OFString *) *files, + OFString *archiveComment) { OFMutableArray *expandedFiles = [OFMutableArray arrayWithCapacity: files.count]; OFFileManager *fileManager = [OFFileManager defaultManager]; @@ -176,20 +184,27 @@ [fileManager subpathsOfDirectoryAtPath: file]]; else [expandedFiles addObject: file]; } - [archive addFiles: expandedFiles]; + if (expandedFiles.count < 1) { + [OFStdErr writeLine: OF_LOCALIZED(@"add_no_file_specified", + @"Need one or more files to add!")]; + [OFApplication terminateWithStatus: 1]; + } + + [archive addFiles: expandedFiles archiveComment: archiveComment]; } @implementation OFArc - (void)applicationDidFinishLaunching: (OFNotification *)notification { - OFString *outputDir, *encodingString, *type; + 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 }, @@ -375,11 +390,11 @@ archive = [self openArchiveWithIRI: IRI type: type mode: mode encoding: encoding]; - addFiles(archive, files); + addFiles(archive, files, archiveComment); break; case 'l': if (remainingArguments.count != 1) help(OFStdErr, false, 1); @@ -647,12 +662,12 @@ @"File %[file] is not a valid archive!", @"file", IRI.string)]; goto error; } - if ((mode == 'a' || mode == 'c') && - ![archive respondsToSelector: @selector(addFiles:)]) { + if ((mode == 'a' || mode == 'c') && ![archive respondsToSelector: + @selector(addFiles:archiveComment:)]) { writingNotSupported(type); goto error; } return archive; Index: utils/ofarc/TarArchive.m ================================================================== --- utils/ofarc/TarArchive.m +++ utils/ofarc/TarArchive.m @@ -478,20 +478,14 @@ app->_exitStatus = 1; } } - (void)addFiles: (OFArray OF_GENERIC(OFString *) *)files + archiveComment: (OFString *)archiveComment { OFFileManager *fileManager = [OFFileManager defaultManager]; - if (files.count < 1) { - [OFStdErr writeLine: OF_LOCALIZED(@"add_no_file_specified", - @"Need one or more files to add!")]; - app->_exitStatus = 1; - return; - } - for (OFString *fileName in files) { void *pool = objc_autoreleasePoolPush(); OFFileAttributes attributes; OFFileAttributeType type; OFMutableTarArchiveEntry *entry; Index: utils/ofarc/ZIPArchive.m ================================================================== --- utils/ofarc/ZIPArchive.m +++ utils/ofarc/ZIPArchive.m @@ -463,19 +463,15 @@ [stream close]; } } - (void)addFiles: (OFArray OF_GENERIC(OFString *) *)files + archiveComment: (OFString *)archiveComment { OFFileManager *fileManager = [OFFileManager defaultManager]; - if (files.count < 1) { - [OFStdErr writeLine: OF_LOCALIZED(@"add_no_file_specified", - @"Need one or more files to add!")]; - app->_exitStatus = 1; - return; - } + _archive.archiveComment = archiveComment; for (OFString *localFileName in files) { void *pool = objc_autoreleasePoolPush(); OFArray OF_GENERIC (OFString *) *components; OFString *fileName; Index: utils/ofarc/ZooArchive.m ================================================================== --- utils/ofarc/ZooArchive.m +++ utils/ofarc/ZooArchive.m @@ -447,19 +447,15 @@ app->_exitStatus = 1; } } - (void)addFiles: (OFArray OF_GENERIC(OFString *) *)files + archiveComment: (OFString *)archiveComment { OFFileManager *fileManager = [OFFileManager defaultManager]; - if (files.count < 1) { - [OFStdErr writeLine: OF_LOCALIZED(@"add_no_file_specified", - @"Need one or more files to add!")]; - app->_exitStatus = 1; - return; - } + _archive.archiveComment = archiveComment; for (OFString *fileName in files) { void *pool = objc_autoreleasePoolPush(); OFFileAttributes attributes; OFFileAttributeType type; Index: utils/ofarc/localization/de.json ================================================================== --- utils/ofarc/localization/de.json +++ utils/ofarc/localization/de.json @@ -13,27 +13,32 @@ usage: [ "Benutzung: %[prog] -[acCfhlnpqtvx] archiv.zip [datei1 datei2 ...]" ], full_usage: [ "Optionen:\n", - " -a --append Zu Archiv hinzufügen\n", - " -c --create Archiv erstellen\n", - " -C --directory= In angegebenes Verzeichnis entpacken\n", - " -E --encoding= Das Encoding des Archivs (nur tar-, ", - "lha- und zoo-Dateien)\n", - " -f --force Existierende Dateien überschreiben\n", - " -h --help Diese Hilfe anzeigen\n", - " --iri Eine IRI benutzen um auf das Archiv zuzugreifen", - "\n", - " -l --list Alle Dateien im Archiv auflisten\n", - " -n --no-clobber Dateien niemals überschreiben\n", - " -p --print Eine oder mehr Dateien aus dem Archiv ausgeben", - "\n", - " -q --quiet Ruhiger Modus (keine Ausgabe außer Fehler)\n", - " -t --type= Archiv-Typ (gz, lha, tar, tgz, zip, zoo)\n", - " -v --verbose Ausführlicher Modus für Datei-Liste\n", - " -x --extract Dateien entpacken" + " -a --append Zu Archiv hinzufügen\n", + " --archive-comment= Zu benutzender Archivkommentar beim ", + "Erstellen oder\n", + " Hinzufügen\n", + " -c --create Archiv erstellen\n", + " -C --directory= In angegebenes Verzeichnis entpacken\n", + " -E --encoding= Das Encoding des Archivs\n", + " (nur tar-, lha- und zoo-Dateien)\n", + " -f --force Existierende Dateien überschreiben\n", + " -h --help Diese Hilfe anzeigen\n", + " --iri Eine IRI benutzen um auf das Archiv ", + "zuzugreifen\n", + " -l --list Alle Dateien im Archiv auflisten\n", + " -n --no-clobber Dateien niemals überschreiben\n", + " -p --print Eine oder mehr Dateien aus dem Archiv ", + "ausgeben\n", + " -q --quiet Ruhiger Modus (keine Ausgabe außer ", + "Fehler)\n", + " -t --type= Archiv-Typ (gz, lha, tar, tgz, zip, ", + "zoo)\n", + " -v --verbose Ausführlicher Modus für Datei-Liste\n", + " -x --extract Dateien entpacken" ], "2_options_mutually_exclusive": [ "Fehler: -%[shortopt1] / --%[longopt1] und ", "-%[shortopt2] / --%[longopt2] schließen sich gegenseitig aus!" ],