Skip to content
Permalink
Browse files

Added test integrity for the cfile compressors: gzip, bzip2, etc. But…

… since most of them shows the message with file status to STDERR instead of STDOUT whe should show both in Test result window.
  • Loading branch information...
stokito authored and raveit65 committed Oct 27, 2018
1 parent a699fa2 commit ab9e18f7411862f89e23d8aa451b26a4df9a3a72
Showing with 60 additions and 19 deletions.
  1. +35 −1 src/fr-command-cfile.c
  2. +25 −18 src/fr-window.c
@@ -469,6 +469,39 @@ fr_command_cfile_extract (FrCommand *comm,
g_free (temp_dir);
}

static void
fr_command_cfile_test (FrCommand *comm)
{
const char *compress_cmd;
if (is_mime_type (comm->mime_type, "application/x-gzip")) {
compress_cmd = "gzip";
}
else if (is_mime_type (comm->mime_type, "application/x-bzip")) {
compress_cmd = "bzip2";
}
else if (is_mime_type (comm->mime_type, "application/x-compress")) {
compress_cmd = is_program_in_path ("gzip") ? "gzip" : "uncompress";
}
else if (is_mime_type (comm->mime_type, "application/x-lzip")) {
compress_cmd = "lzip";
}
else if (is_mime_type (comm->mime_type, "application/x-lzma")) {
compress_cmd = "lzma";
}
else if (is_mime_type (comm->mime_type, "application/x-xz")) {
compress_cmd = "xz";
}
else if (is_mime_type (comm->mime_type, "application/x-lzop")) {
compress_cmd = "lzop";
} else { // i.e. if (is_mime_type (comm->mime_type, "application/x-rzip"))
g_warning ("Test integrity in unsupported for %s\n", comm->mime_type);
return;
}
fr_process_begin_command (comm->process, compress_cmd);
fr_process_add_arg (comm->process, "-vt"); // verbose and test
fr_process_add_arg (comm->process, comm->filename);
fr_process_end_command (comm->process);
}

const char *cfile_mime_type[] = { "application/x-gzip",
"application/x-brotli",
@@ -594,6 +627,7 @@ fr_command_cfile_class_init (FrCommandCFileClass *class)
afc->add = fr_command_cfile_add;
afc->delete = fr_command_cfile_delete;
afc->extract = fr_command_cfile_extract;
afc->test = fr_command_cfile_test;
afc->get_mime_types = fr_command_cfile_get_mime_types;
afc->get_capabilities = fr_command_cfile_get_capabilities;
afc->get_packages = fr_command_cfile_get_packages;
@@ -609,7 +643,7 @@ fr_command_cfile_init (FrCommand *comm)
comm->propExtractCanSkipOlder = FALSE;
comm->propExtractCanJunkPaths = FALSE;
comm->propPassword = FALSE;
comm->propTest = FALSE;
comm->propTest = TRUE;
}


@@ -7400,6 +7400,27 @@ last_output_window__unrealize_cb (GtkWidget *widget,
}


static void
fr_window_view_last_output_print(GtkTextBuffer *text_buffer,
GtkTextIter *iter,
GList *scan)
{
for (; scan; scan = scan->next) {
char *line = scan->data;
char *utf8_line;
gsize bytes_written;

utf8_line = g_locale_to_utf8 (line, -1, NULL, &bytes_written, NULL);
gtk_text_buffer_insert_with_tags_by_name (text_buffer,
iter,
utf8_line,
bytes_written,
"monospace", NULL);
g_free (utf8_line);
gtk_text_buffer_insert (text_buffer, iter, "\n", 1);
}
}

void
fr_window_view_last_output (FrWindow *window,
const char *title)
@@ -7410,7 +7431,6 @@ fr_window_view_last_output (FrWindow *window,
GtkWidget *scrolled;
GtkTextBuffer *text_buffer;
GtkTextIter iter;
GList *scan;

if (title == NULL)
title = _("Last Output");
@@ -7468,24 +7488,11 @@ fr_window_view_last_output (FrWindow *window,
G_CALLBACK (last_output_window__unrealize_cb),
NULL);

/**/

gtk_text_buffer_get_iter_at_offset (text_buffer, &iter, 0);
scan = window->archive->process->out.raw;
for (; scan; scan = scan->next) {
char *line = scan->data;
char *utf8_line;
gsize bytes_written;

utf8_line = g_locale_to_utf8 (line, -1, NULL, &bytes_written, NULL);
gtk_text_buffer_insert_with_tags_by_name (text_buffer,
&iter,
utf8_line,
bytes_written,
"monospace", NULL);
g_free (utf8_line);
gtk_text_buffer_insert (text_buffer, &iter, "\n", 1);
}
/* Show STDOUT of process */
fr_window_view_last_output_print(text_buffer, &iter, window->archive->process->out.raw);
/* Show STDERR of process */
fr_window_view_last_output_print(text_buffer, &iter, window->archive->process->err.raw);

/**/

0 comments on commit ab9e18f

Please sign in to comment.
You can’t perform that action at this time.