diff options
author | rbuj <[email protected]> | 2019-12-31 16:23:35 +0100 |
---|---|---|
committer | lukefromdc <[email protected]> | 2020-03-10 05:15:02 +0000 |
commit | 767517e2ec741f69e29a3af8f8bb0dd2abee6e81 (patch) | |
tree | d95a15d67d86f4bc4a3ddd16d943df7fd6ba461b | |
parent | 144ac2fb1395a76a04773c577965a8754f2dab3b (diff) | |
download | engrampa-767517e2ec741f69e29a3af8f8bb0dd2abee6e81.tar.bz2 engrampa-767517e2ec741f69e29a3af8f8bb0dd2abee6e81.tar.xz |
Add ARC archive support
-rw-r--r-- | README | 1 | ||||
-rw-r--r-- | caja/caja-engrampa.c | 1 | ||||
-rw-r--r-- | data/engrampa.desktop.in.in | 2 | ||||
-rw-r--r-- | po/POTFILES.in | 2 | ||||
-rw-r--r-- | src/Makefile.am | 2 | ||||
-rw-r--r-- | src/fr-command-nomarch.c | 322 | ||||
-rw-r--r-- | src/fr-command-nomarch.h | 54 | ||||
-rw-r--r-- | src/fr-init.c | 4 |
8 files changed, 387 insertions, 1 deletions
@@ -19,6 +19,7 @@ * WinAce Compressed File (.ace) * ALZip Compressed File (.alz) * AIX Small Indexed Archive (.ar) + * ARC Archive (.arc) * ARJ Compressed Archive (.arj) * Cabinet File (.cab) * UNIX CPIO Archive (.cpio) diff --git a/caja/caja-engrampa.c b/caja/caja-engrampa.c index af19d25..ab32d59 100644 --- a/caja/caja-engrampa.c +++ b/caja/caja-engrampa.c @@ -149,6 +149,7 @@ static struct { { "application/x-7z-compressed-tar", TRUE }, { "application/x-ace", TRUE }, { "application/x-alz", TRUE }, + { "application/x-arc", TRUE }, { "application/x-archive", TRUE }, { "application/x-arj", TRUE }, { "application/x-brotli", TRUE }, diff --git a/data/engrampa.desktop.in.in b/data/engrampa.desktop.in.in index 59295fd..a118adf 100644 --- a/data/engrampa.desktop.in.in +++ b/data/engrampa.desktop.in.in @@ -11,7 +11,7 @@ Type=Application Icon=engrampa # Translators: Search terms to find this application. Do NOT translate or localize the semicolons! The list MUST also end with a semicolon! Categories=GTK;Utility;Archiving;Compression; -MimeType=application/x-7z-compressed;application/x-7z-compressed-tar;application/x-ace;application/x-alz;application/x-arj;application/x-brotli;application/x-brotli-compressed-tar;application/x-bzip;application/x-bzip-compressed-tar;application/x-bzip1;application/x-bzip1-compressed-tar;application/x-cabinet;application/x-cbr;application/x-cbz;application/x-cd-image;application/x-compress;application/x-compressed-tar;application/x-cpio;application/vnd.debian.binary-package;application/x-ear;application/x-ms-dos-executable;application/x-gtar;application/x-gzip;application/x-gzpostscript;application/x-java-archive;application/x-lha;application/x-lzh-compressed;application/x-lrzip;application/x-lrzip-compressed-tar;application/x-lzip;application/x-lzip-compressed-tar;application/x-lzma;application/x-lzma-compressed-tar;application/x-lzop;application/x-lzop-compressed-tar;application/x-ms-wim;application/x-rar;application/x-rar-compressed;application/x-rpm;application/x-source-rpm;application/x-rzip;application/x-tar;application/x-tarz;application/x-stuffit;application/x-war;application/x-xz;application/x-xz-compressed-tar;application/x-zip;application/x-zip-compressed;application/x-zoo;@ZSTD_MIME_TYPE@;application/x-zstd-compressed-tar;application/zip;application/x-archive;application/vnd.ms-cab-compressed; +MimeType=application/x-7z-compressed;application/x-7z-compressed-tar;application/x-ace;application/x-alz;application/x-arc;application/x-arj;application/x-brotli;application/x-brotli-compressed-tar;application/x-bzip;application/x-bzip-compressed-tar;application/x-bzip1;application/x-bzip1-compressed-tar;application/x-cabinet;application/x-cbr;application/x-cbz;application/x-cd-image;application/x-compress;application/x-compressed-tar;application/x-cpio;application/vnd.debian.binary-package;application/x-ear;application/x-ms-dos-executable;application/x-gtar;application/x-gzip;application/x-gzpostscript;application/x-java-archive;application/x-lha;application/x-lzh-compressed;application/x-lrzip;application/x-lrzip-compressed-tar;application/x-lzip;application/x-lzip-compressed-tar;application/x-lzma;application/x-lzma-compressed-tar;application/x-lzop;application/x-lzop-compressed-tar;application/x-ms-wim;application/x-rar;application/x-rar-compressed;application/x-rpm;application/x-source-rpm;application/x-rzip;application/x-tar;application/x-tarz;application/x-stuffit;application/x-war;application/x-xz;application/x-xz-compressed-tar;application/x-zip;application/x-zip-compressed;application/x-zoo;@ZSTD_MIME_TYPE@;application/x-zstd-compressed-tar;application/zip;application/x-archive;application/vnd.ms-cab-compressed; # Translators: Search terms to find this application. Do NOT translate or localize the semicolons! The list MUST also end with a semicolon! Keywords=MATE;archive;manager;compression; X-MATE-DocPath=engrampa/engrampa.xml diff --git a/po/POTFILES.in b/po/POTFILES.in index a87d27e..9dc61eb 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -76,6 +76,8 @@ src/fr-command-lha.c src/fr-command-lha.h src/fr-command-lrzip.c src/fr-command-lrzip.h +src/fr-command-nomarch.c +src/fr-command-nomarch.h src/fr-command-rar.c src/fr-command-rar.h src/fr-command-rpm.c diff --git a/src/Makefile.am b/src/Makefile.am index 43cb092..2f14c1d 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -103,6 +103,8 @@ COMMON_SOURCES = \ fr-command-jar.c \ fr-command-lha.c \ fr-command-lha.h \ + fr-command-nomarch.c \ + fr-command-nomarch.h \ fr-command-rar.c \ fr-command-rar.h \ fr-command-rpm.c \ diff --git a/src/fr-command-nomarch.c b/src/fr-command-nomarch.c new file mode 100644 index 0000000..c23248a --- /dev/null +++ b/src/fr-command-nomarch.c @@ -0,0 +1,322 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ + +/* + * Engrampa + * + * Copyright (C) 2001, 2003 Free Software Foundation, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#define _XOPEN_SOURCE /* strptime */ + +#include <stdlib.h> +#include <string.h> +#include <time.h> + +#include <glib.h> + +#include "file-data.h" +#include "file-utils.h" +#include "glib-utils.h" +#include "fr-command.h" +#include "fr-command-nomarch.h" + +#define LSNOMARCH_DATE_FORMAT "%Y-%m-%d %H:%M" + +static void fr_command_nomarch_class_init (FrCommandNomarchClass *class); +static void fr_command_nomarch_init (FrCommand *afile); +static void fr_command_nomarch_finalize (GObject *object); + +/* Parent Class */ + +static FrCommandClass *parent_class = NULL; + + +/* -- list -- */ + +static time_t +mktime_from_string (const char *time_s) +{ + struct tm tm = {0, }; + tm.tm_isdst = -1; + strptime (time_s, LSNOMARCH_DATE_FORMAT, &tm); + return mktime (&tm); +} + +static void +list__process_line (char *line, + gpointer data) +{ + FileData *fdata; + FrCommand *comm = FR_COMMAND (data); + char **fields; + int date_idx; + char *field_date, *field_name; + + g_return_if_fail (line != NULL); + + date_idx = file_list__get_index_from_pattern (line, "%n%n%n%n-%n%n-%n%n %n%n:%n%n"); + if (date_idx < 0) + return; + + fdata = file_data_new (); + fields = split_line (line, 8); + + field_name = fields[0]; + fdata->full_path = g_strconcat ("/", field_name, NULL); + fdata->original_path = fdata->full_path + 1; + fdata->name = g_strdup (file_name_from_path (fdata->full_path)); + fdata->path = remove_level_from_path (fdata->full_path); + + fdata->size = g_ascii_strtoull (fields[4], NULL, 10); + + field_date = g_strndup (line + date_idx, 16); + fdata->modified = mktime_from_string (field_date); + g_free (field_date); + + g_strfreev (fields); + + if (*fdata->name == 0) + file_data_free (fdata); + else + fr_command_add_file (comm, fdata); +} + + +static void +fr_command_nomarch_list (FrCommand *comm) +{ + fr_process_set_out_line_func (comm->process, list__process_line, comm); + + fr_process_begin_command (comm->process, "nomarch"); + fr_process_add_arg (comm->process, "-lvU"); + fr_process_add_arg (comm->process, comm->filename); + fr_process_end_command (comm->process); + fr_process_start (comm->process); +} + + +static void +fr_command_nomarch_add (FrCommand *comm, + const char *from_file, + GList *file_list, + const char *base_dir, + gboolean update, + gboolean recursive) +{ + GList *scan; + + fr_process_begin_command (comm->process, "arc"); + + if (base_dir != NULL) + fr_process_set_working_dir (comm->process, base_dir); + + if (update) + fr_process_add_arg (comm->process, "u"); + else + fr_process_add_arg (comm->process, "a"); + + fr_process_add_arg (comm->process, comm->filename); + + for (scan = file_list; scan; scan = scan->next) + fr_process_add_arg (comm->process, (gchar*) scan->data); + + fr_process_end_command (comm->process); +} + + +static void +fr_command_nomarch_delete (FrCommand *comm, + const char *from_file, + GList *file_list) +{ + GList *scan; + + fr_process_begin_command (comm->process, "arc"); + fr_process_add_arg (comm->process, "d"); + + fr_process_add_arg (comm->process, comm->filename); + + for (scan = file_list; scan; scan = scan->next) + fr_process_add_arg (comm->process, scan->data); + fr_process_end_command (comm->process); +} + + +static void +fr_command_nomarch_extract (FrCommand *comm, + const char *from_file, + GList *file_list, + const char *dest_dir, + gboolean overwrite, + gboolean skip_older, + gboolean junk_paths) +{ + GList *scan; + + fr_process_begin_command (comm->process, "nomarch"); + + if (dest_dir != NULL) + fr_process_set_working_dir (comm->process, dest_dir); + + fr_process_add_arg (comm->process, "-U"); + fr_process_add_arg (comm->process, comm->filename); + for (scan = file_list; scan; scan = scan->next) + fr_process_add_arg (comm->process, scan->data); + + fr_process_end_command (comm->process); +} + + +static void +fr_command_nomarch_test (FrCommand *comm) +{ + fr_process_begin_command (comm->process, "nomarch"); + fr_process_add_arg (comm->process, "-tU"); + fr_process_add_arg (comm->process, comm->filename); + fr_process_end_command (comm->process); +} + + +static void +fr_command_nomarch_handle_error (FrCommand *comm, + FrProcError *error) +{ + if (error->type != FR_PROC_ERROR_NONE) { + if (error->status <= 1) + error->type = FR_PROC_ERROR_NONE; + else if (error->status == 3) + error->type = FR_PROC_ERROR_ASK_PASSWORD; + } +} + + +const char *nomarch_mime_type[] = { "application/x-arc", NULL }; + + +static const char ** +fr_command_nomarch_get_mime_types (FrCommand *comm) +{ + return nomarch_mime_type; +} + + +static FrCommandCap +fr_command_nomarch_get_capabilities (FrCommand *comm, + const char *mime_type, + gboolean check_command) +{ + FrCommandCap capabilities; + + capabilities = FR_COMMAND_CAN_ARCHIVE_MANY_FILES; + if (is_program_available ("nomarch", check_command)) { + capabilities |= FR_COMMAND_CAN_READ; + if (is_program_available ("arc", check_command)) + capabilities |= FR_COMMAND_CAN_WRITE; + } + return capabilities; +} + + +static const char * +fr_command_nomarch_get_packages (FrCommand *comm, + const char *mime_type) +{ + return PACKAGES ("nomarch,arc"); +} + + +static void +fr_command_nomarch_class_init (FrCommandNomarchClass *class) +{ + GObjectClass *gobject_class = G_OBJECT_CLASS (class); + FrCommandClass *afc; + + parent_class = g_type_class_peek_parent (class); + afc = (FrCommandClass*) class; + + gobject_class->finalize = fr_command_nomarch_finalize; + + afc->list = fr_command_nomarch_list; + afc->add = fr_command_nomarch_add; + afc->delete = fr_command_nomarch_delete; + afc->extract = fr_command_nomarch_extract; + afc->test = fr_command_nomarch_test; + afc->handle_error = fr_command_nomarch_handle_error; + afc->get_mime_types = fr_command_nomarch_get_mime_types; + afc->get_capabilities = fr_command_nomarch_get_capabilities; + afc->get_packages = fr_command_nomarch_get_packages; +} + + +static void +fr_command_nomarch_init (FrCommand *comm) +{ + FrCommandNomarch *nomarch_comm; + + comm->propAddCanUpdate = TRUE; + comm->propAddCanReplace = TRUE; + comm->propAddCanStoreFolders = FALSE; + comm->propExtractCanAvoidOverwrite = TRUE; + comm->propExtractCanSkipOlder = TRUE; + comm->propExtractCanJunkPaths = TRUE; + comm->propPassword = TRUE; + comm->propTest = TRUE; + + nomarch_comm = FR_COMMAND_NOMARCH (comm); + nomarch_comm->fdata = FALSE; +} + + +static void +fr_command_nomarch_finalize (GObject *object) +{ + g_return_if_fail (object != NULL); + g_return_if_fail (FR_IS_COMMAND_NOMARCH (object)); + + /* Chain up */ + if (G_OBJECT_CLASS (parent_class)->finalize) + G_OBJECT_CLASS (parent_class)->finalize (object); +} + + +GType +fr_command_nomarch_get_type () +{ + static GType type = 0; + + if (! type) { + GTypeInfo type_info = { + sizeof (FrCommandNomarchClass), + NULL, + NULL, + (GClassInitFunc) fr_command_nomarch_class_init, + NULL, + NULL, + sizeof (FrCommandNomarch), + 0, + (GInstanceInitFunc) fr_command_nomarch_init, + NULL + }; + + type = g_type_register_static (FR_TYPE_COMMAND, + "FRCommandNomarch", + &type_info, + 0); + } + + return type; +} diff --git a/src/fr-command-nomarch.h b/src/fr-command-nomarch.h new file mode 100644 index 0000000..820d795 --- /dev/null +++ b/src/fr-command-nomarch.h @@ -0,0 +1,54 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ + +/* + * Engrampa + * + * Copyright (C) 2001, 2003 Free Software Foundation, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#ifndef FR_COMMAND_NOMARCH_H +#define FR_COMMAND_NOMARCH_H + +#include <glib.h> +#include "fr-command.h" +#include "fr-process.h" + +#define FR_TYPE_COMMAND_NOMARCH (fr_command_nomarch_get_type ()) +#define FR_COMMAND_NOMARCH(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), FR_TYPE_COMMAND_NOMARCH, FrCommandNomarch)) +#define FR_COMMAND_NOMARCH_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), FR_TYPE_COMMAND_NOMARCH, FrCommandNomarchClass)) +#define FR_IS_COMMAND_NOMARCH(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), FR_TYPE_COMMAND_NOMARCH)) +#define FR_IS_COMMAND_NOMARCH_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), FR_TYPE_COMMAND_NOMARCH)) +#define FR_COMMAND_NOMARCH_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), FR_TYPE_COMMAND_NOMARCH, FrCommandNomarchClass)) + +typedef struct _FrCommandNomarch FrCommandNomarch; +typedef struct _FrCommandNomarchClass FrCommandNomarchClass; + +struct _FrCommandNomarch +{ + FrCommand __parent; + + FileData *fdata; +}; + +struct _FrCommandNomarchClass +{ + FrCommandClass __parent_class; +}; + +GType fr_command_nomarch_get_type (void); + +#endif /* FR_COMMAND_NOMARCH_H */ diff --git a/src/fr-init.c b/src/fr-init.c index 67393f1..fa5d026 100644 --- a/src/fr-init.c +++ b/src/fr-init.c @@ -36,6 +36,7 @@ #include "fr-command-iso.h" #include "fr-command-jar.h" #include "fr-command-lha.h" +#include "fr-command-nomarch.h" #include "fr-command-rar.h" #include "fr-command-rpm.h" #include "fr-command-tar.h" @@ -70,6 +71,7 @@ FrMimeTypeDescription mime_type_desc[] = { { "application/x-7z-compressed-tar", ".tar.7z", N_("Tar compressed with 7z"), 0 }, { "application/x-ace", ".ace", N_("Ace"), 0 }, { "application/x-alz", ".alz", N_("ALZip archive"), 0 }, + { "application/x-arc", ".arc", N_("ARC archive"), 0 }, { "application/x-archive", ".ar", N_("Ar"), 0 }, { "application/x-arj", ".arj", N_("Arj"), 0 }, { "application/x-brotli", ".br", N_("Brotli compressed file"), 0 }, @@ -120,6 +122,7 @@ FrExtensionType file_ext_type[] = { { ".ace", "application/x-ace" }, { ".alz", "application/x-alz" }, { ".ar", "application/x-archive" }, + { ".arc", "application/x-arc" }, { ".arj", "application/x-arj" }, { ".bin", "application/x-stuffit" }, { ".br", "application/x-brotli" }, @@ -370,6 +373,7 @@ register_commands (void) register_command (FR_TYPE_COMMAND_ACE); register_command (FR_TYPE_COMMAND_ALZ); register_command (FR_TYPE_COMMAND_AR); + register_command (FR_TYPE_COMMAND_NOMARCH); register_command (FR_TYPE_COMMAND_ARJ); register_command (FR_TYPE_COMMAND_CPIO); register_command (FR_TYPE_COMMAND_ISO); |