Exemplo n.º 1
0
static void
fr_command_tar_delete (FrCommand  *comm,
		       const char *from_file,
		       GList      *file_list)
{
	FrCommandTar *c_tar = FR_COMMAND_TAR (comm);
	GList        *scan;

	fr_process_set_out_line_func (comm->process,
				      process_line__delete,
				      comm);

	begin_tar_command (comm);
	fr_process_set_begin_func (comm->process, begin_func__delete, comm);
	fr_process_add_arg (comm->process, "--force-local");
	fr_process_add_arg (comm->process, "--no-wildcards");
	fr_process_add_arg (comm->process, "-v");
	fr_process_add_arg (comm->process, "--delete");
	fr_process_add_arg (comm->process, "-f");
	fr_process_add_arg (comm->process, c_tar->uncomp_filename);

	if (from_file != NULL) {
		fr_process_add_arg (comm->process, "-T");
		fr_process_add_arg (comm->process, from_file);
	}

	fr_process_add_arg (comm->process, "--");

	if (from_file == NULL)
		for (scan = file_list; scan; scan = scan->next)
			fr_process_add_arg (comm->process, scan->data);

	fr_process_end_command (comm->process);
}
Exemplo n.º 2
0
static void
fr_command_zoo_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, "zoo");

	if (overwrite)
		fr_process_add_arg (comm->process, "xO");
	else
		fr_process_add_arg (comm->process, "x");

	fr_process_add_arg (comm->process, comm->filename);

	if (dest_dir != NULL)
		fr_process_set_working_dir (comm->process, dest_dir);

	for (scan = file_list; scan; scan = scan->next)
		fr_process_add_arg (comm->process, scan->data);

	fr_process_end_command (comm->process);
}
Exemplo n.º 3
0
static void
fr_command_zoo_add (FrCommand     *comm,
		    const char    *from_file,
		    GList         *file_list,
		    const char    *base_dir,
		    gboolean       update,
		    gboolean       recursive)
{
	GList        *scan;

	/* Add files. */

	fr_process_begin_command (comm->process, "zoo");

	fr_process_set_working_dir (comm->process, base_dir);

	if (update)
		fr_process_add_arg (comm->process, "auP");
	else
		fr_process_add_arg (comm->process, "aP");

	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_unstuff_list (FrCommand *comm)
{
	char *arg, *path;
	char *filename;
	char *path_dots;

	fr_process_set_out_line_func (comm->process, process_line, comm);

	fr_process_begin_command (comm->process, "unstuff");
	fr_process_set_begin_func (comm->process, list__begin, comm);
	fr_process_add_arg (comm->process, "--trace");

	/* Actually unpack everything in a temporary directory */
	path = get_temp_work_dir (NULL);
	path_dots = unstuff_is_shit_with_filenames (path);
	g_free (path);

	arg = g_strdup_printf ("-d=%s", path_dots);
	FR_COMMAND_UNSTUFF (comm)->target_dir = path_dots;
	fr_process_add_arg (comm->process, arg);
	g_free (arg);

	filename = unstuff_is_shit_with_filenames (comm->filename);
	fr_process_add_arg (comm->process, filename);
	g_free (filename);
	fr_process_end_command (comm->process);
	fr_process_start (comm->process);
}
Exemplo n.º 5
0
static void
add_compress_arg (FRCommand *comm)
{
   FRCommandTar *comm_tar = FR_COMMAND_TAR (comm);

   switch (comm_tar->compress_prog) {
   case FR_COMPRESS_PROGRAM_NONE:
      break;

   case FR_COMPRESS_PROGRAM_GZIP:
      fr_process_add_arg (comm->process, "-z");
      break;

   case FR_COMPRESS_PROGRAM_BZIP:
      fr_process_add_arg (comm->process, 
                          "--use-compress-program bzip");
      break;

   case FR_COMPRESS_PROGRAM_BZIP2:
      fr_process_add_arg (comm->process, "--bzip");
      break;

   case FR_COMPRESS_PROGRAM_COMPRESS:
      fr_process_add_arg (comm->process, "-Z");
      break;
   case FR_COMPRESS_PROGRAM_LZO:
      fr_process_add_arg (comm->process, 
                          "--use-compress-program lzop");
      break;
   }
}
Exemplo n.º 6
0
static void
fr_command_zip_delete (FrCommand  *comm,
		       const char *from_file,
		       GList      *file_list)
{
	GList *scan;

	fr_process_set_out_line_func (FR_COMMAND (comm)->process,
				      process_line__common,
				      comm);

	fr_process_begin_command (comm->process, "zip");
	fr_process_add_arg (comm->process, "-d");

	fr_process_add_arg (comm->process, comm->filename);
	for (scan = file_list; scan; scan = scan->next) {
		char *escaped;

 		escaped = escape_str (scan->data, ZIP_SPECIAL_CHARACTERS);
 		fr_process_add_arg (comm->process, escaped);
 		g_free (escaped);
	}

	fr_process_end_command (comm->process);
}
Exemplo n.º 7
0
static void
fr_command_zoo_test (FrCommand   *comm)
{
	fr_process_begin_command (comm->process, "zoo");
	fr_process_add_arg (comm->process, "-test");
	fr_process_add_arg (comm->process, comm->filename);
	fr_process_end_command (comm->process);
}
Exemplo n.º 8
0
static void
fr_command_zip_test (FrCommand   *comm)
{
	fr_process_begin_command (comm->process, "unzip");
	fr_process_add_arg (comm->process, "-t");
	add_password_arg (comm, comm->password);
	fr_process_add_arg (comm->process, comm->filename);
	fr_process_end_command (comm->process);
}
Exemplo n.º 9
0
static void
add_password_arg (FrCommand  *comm,
		  const char *password)
{
	if ((password != NULL) && (password[0] != '\0')) {
		fr_process_add_arg (comm->process, "-P");
		fr_process_add_arg (comm->process, password);
	}
}
Exemplo n.º 10
0
static void
fr_command_ace_test (FrCommand   *comm)
{
        fr_process_begin_command (comm->process, "unace");
        fr_process_add_arg (comm->process, "t");
	fr_process_add_arg (comm->process, "-y");
	fr_process_add_arg (comm->process, comm->filename);
        fr_process_end_command (comm->process);
}
static void
fr_command_cfile_list (FrCommand  *comm)
{
	FrCommandCFile *comm_cfile = FR_COMMAND_CFILE (comm);

	if (is_mime_type (comm->mime_type, "application/x-gzip")) {
		/* gzip let us known the uncompressed size */

		fr_process_set_out_line_func (FR_COMMAND (comm)->process,
					      list__process_line,
					      comm);

		fr_process_begin_command (comm->process, "gzip");
		fr_process_add_arg (comm->process, "-l");
		fr_process_add_arg (comm->process, "-q");
		fr_process_add_arg (comm->process, comm->filename);
		fr_process_end_command (comm->process);
		fr_process_start (comm->process);
	}
	else {
		/* ... other compressors do not support this feature so
		 * simply use the archive size, suboptimal but there is no
		 * alternative. */

		FileData *fdata;
		char     *filename;

		fdata = file_data_new ();

		filename = remove_extension_from_path (comm->filename);
		fdata->full_path = g_strconcat ("/",
						file_name_from_path (filename),
						NULL);
		g_free (filename);

		fdata->original_path = fdata->full_path + 1;
		fdata->link = NULL;
		fdata->size = get_file_size_for_path (comm->filename);
		fdata->modified = get_file_mtime_for_path (comm->filename);

		fdata->name = g_strdup (file_name_from_path (fdata->full_path));
		fdata->path = remove_level_from_path (fdata->full_path);

		if (*fdata->name == 0)
			file_data_free (fdata);
		else
			fr_command_add_file (comm, fdata);

		comm_cfile->error.type = FR_PROC_ERROR_NONE;
		comm_cfile->error.status = 0;
		g_signal_emit_by_name (G_OBJECT (comm),
				       "done",
				       comm->action,
				       &comm_cfile->error);
	}
}
Exemplo n.º 12
0
static void
fr_command_zoo_list (FrCommand  *zoo_comm)
{
	fr_process_set_out_line_func (zoo_comm->process, process_zoo_line, zoo_comm);

	fr_process_begin_command (zoo_comm->process, "zoo");
	fr_process_add_arg (zoo_comm->process, "lq");
	fr_process_add_arg (zoo_comm->process, zoo_comm->filename);
	fr_process_end_command (zoo_comm->process);
	fr_process_start (zoo_comm->process);
}
Exemplo n.º 13
0
static void
fr_command_tar_list (FRCommand *comm)
{
   fr_process_clear (comm->process);
   fr_process_begin_command (comm->process, "tar");
   fr_process_add_arg (comm->process, "-tvf");
   fr_process_add_arg (comm->process, comm->filename);
   add_compress_arg (comm);
   fr_process_end_command (comm->process);
   fr_process_start (comm->process, TRUE);
}
Exemplo n.º 14
0
static void
fr_command_ar_list (FrCommand *comm)
{
	fr_process_set_out_line_func (comm->process, process_line, comm);

	fr_process_begin_command (comm->process, "ar");
	fr_process_add_arg (comm->process, "tv");
	fr_process_add_arg (comm->process, comm->filename);
	fr_process_end_command (comm->process);
	fr_process_start (comm->process);
}
Exemplo n.º 15
0
static gboolean
fr_command_lrzip_list (FrCommand  *comm)
{
	fr_process_set_err_line_func (comm->process, list__process_line, comm);

	fr_process_begin_command (comm->process, "lrzip");
	fr_process_add_arg (comm->process, "-i");
	fr_process_add_arg (comm->process, comm->filename);
	fr_process_end_command (comm->process);

	return TRUE;
}
Exemplo n.º 16
0
static void
fr_command_zip_list (FrCommand  *comm)
{
	fr_process_set_out_line_func (comm->process, list__process_line, comm);

	fr_process_begin_command (comm->process, "unzip");
	fr_process_set_begin_func (comm->process, list__begin, comm);
	fr_process_add_arg (comm->process, "-ZTs");
	fr_process_add_arg (comm->process, comm->filename);
	fr_process_end_command (comm->process);
	fr_process_start (comm->process);
}
Exemplo n.º 17
0
static void
fr_command_arj_test (FrCommand   *comm)
{
	fr_process_begin_command (comm->process, "arj");
	fr_process_add_arg (comm->process, "t");
	if (comm->password != NULL)
		fr_process_add_arg_concat (comm->process, "-g/", comm->password, NULL);
	fr_process_add_arg (comm->process, "-i");
	fr_process_add_arg (comm->process, "-y");
	fr_process_add_arg (comm->process, "-");
	fr_process_add_arg (comm->process, comm->filename);
	fr_process_end_command (comm->process);
}
Exemplo n.º 18
0
static gboolean
fr_command_ace_list (FrCommand  *comm)
{
	fr_process_set_out_line_func (comm->process, process_line, comm);

	fr_process_begin_command (comm->process, "unace");
	fr_process_set_begin_func (comm->process, list__begin, comm);
	fr_process_add_arg (comm->process, "v");
	fr_process_add_arg (comm->process, "-y");
	fr_process_add_arg (comm->process, comm->filename);
	fr_process_end_command (comm->process);

	return TRUE;
}
static void
fr_command_tar_list (FrCommand *comm)
{
    fr_process_set_out_line_func (comm->process, process_line, comm);

    begin_tar_command (comm);
    fr_process_add_arg (comm->process, "--force-local");
    fr_process_add_arg (comm->process, "--no-wildcards");
    fr_process_add_arg (comm->process, "-tvf");
    fr_process_add_arg (comm->process, comm->filename);
    add_compress_arg (comm);
    fr_process_end_command (comm->process);
    fr_process_start (comm->process);
}
Exemplo n.º 20
0
static void
fr_command_7z_test (FrCommand *command)
{
	FrArchive *archive = FR_ARCHIVE (command);

	fr_command_7z_begin_command (command);
	fr_process_add_arg (command->process, "t");
	fr_process_add_arg (command->process, "-bd");
	fr_process_add_arg (command->process, "-y");
	add_password_arg (command, archive->password, FALSE);
	fr_process_add_arg (command->process, "--");
	fr_process_add_arg (command->process, command->filename);
	fr_process_end_command (command->process);
}
Exemplo n.º 21
0
static void
fr_command_ar_delete (FrCommand  *comm,
		      const char *from_file,
		      GList      *file_list)
{
	GList *scan;

	fr_process_begin_command (comm->process, "ar");
	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);
}
Exemplo n.º 22
0
static void
fr_command_iso_list (FrCommand *comm)
{
	fr_process_set_out_line_func (comm->process, list__process_line, comm);

	fr_process_begin_command (comm->process, "sh");
	fr_process_set_begin_func (comm->process, list__begin, comm);
	fr_process_add_arg (comm->process, SHDIR "isoinfo.sh");
	fr_process_add_arg (comm->process, "-i");
	fr_process_add_arg (comm->process, comm->filename);
	fr_process_add_arg (comm->process, "-l");
	fr_process_end_command (comm->process);

	fr_process_start (comm->process);
}
Exemplo n.º 23
0
static void
fr_command_unarchiver_extract (FrCommand  *comm,
			       const char *from_file,
			       GList      *file_list,
			       const char *dest_dir,
			       gboolean    overwrite,
			       gboolean    skip_older,
			       gboolean    junk_paths)
{
	FrCommandUnarchiver *unar_comm = FR_COMMAND_UNARCHIVER (comm);
	GList               *scan;

	unar_comm->n_line = 0;

	fr_process_use_standard_locale (comm->process, TRUE);
	fr_process_set_out_line_func (comm->process,
				      process_line__extract,
				      comm);

	fr_process_begin_command (comm->process, "unar");

	if (overwrite)
		fr_process_add_arg (comm->process, "-f");
	else
		fr_process_add_arg (comm->process, "-s");

	fr_process_add_arg (comm->process, "-D");

	if ((comm->password != NULL) && (comm->password[0] != '\0'))
		fr_process_add_arg_concat (comm->process, "-password="******"-output-directory=", dest_dir, NULL);

	fr_process_add_arg (comm->process, comm->filename);

	for (scan = file_list; scan; scan = scan->next) {
		char *escaped;

		escaped = escape_str (scan->data, "[");
		fr_process_add_arg (comm->process, escaped);
		g_free (escaped);
	}

	fr_process_end_command (comm->process);
}
static void
fr_command_dpkg_list (FrCommand *comm)
{
        fr_process_set_out_line_func (comm->process, process_data_line, comm);

        fr_process_begin_command (comm->process, "dpkg-deb");
        fr_process_add_arg (comm->process, "-I");
        fr_process_add_arg (comm->process, comm->filename);
        fr_process_end_command (comm->process);
        fr_process_start (comm->process);

        fr_process_begin_command (comm->process, "dpkg-deb");
        fr_process_add_arg (comm->process, "-c");
        fr_process_add_arg (comm->process, comm->filename);
        fr_process_end_command (comm->process);
        fr_process_start (comm->process);
}
Exemplo n.º 25
0
static void
fr_command_lrzip_add (FrCommand  *comm,
		      const char *from_file,
		      GList      *file_list,
		      const char *base_dir,
		      gboolean    update,
		      gboolean    follow_links)
{
	fr_process_begin_command (comm->process, "lrzip");

	if (base_dir != NULL)
		fr_process_set_working_dir (comm->process, base_dir);

	/* preserve links. */

	switch (FR_ARCHIVE (comm)->compression) {
	case FR_COMPRESSION_VERY_FAST:
		fr_process_add_arg (comm->process, "-l"); break;
	case FR_COMPRESSION_FAST:
		fr_process_add_arg (comm->process, "-g"); break;
	case FR_COMPRESSION_NORMAL:
		fr_process_add_arg (comm->process, "-b"); break;
	case FR_COMPRESSION_MAXIMUM:
		fr_process_add_arg (comm->process, "-z"); break;
	}

	fr_process_add_arg (comm->process, "-o");
	fr_process_add_arg (comm->process, comm->filename);
	fr_process_add_arg (comm->process, (char *) file_list->data);

	fr_process_end_command (comm->process);
}
Exemplo n.º 26
0
static void
fr_command_tar_delete (FRCommand *comm,
                       GList *file_list)
{
   GList *scan;
   gchar *new_filename, *new_filename2;
   gboolean name_modified;

   new_filename = uncompress (comm, &name_modified);

   /* Delete files. */

   fr_process_begin_command (comm->process, "tar");
   fr_process_add_arg (comm->process, "--delete");
   fr_process_add_arg (comm->process, "-f");
   fr_process_add_arg (comm->process, new_filename);

   for (scan = file_list; scan; scan = scan->next)
      fr_process_add_arg (comm->process, scan->data);
   fr_process_end_command (comm->process);

   new_filename2 = recompress (comm, new_filename);

   /* Restore original name. */

   if (name_modified) {
      fr_process_begin_command (comm->process, "mv");
      fr_process_add_arg (comm->process, "-f");
      fr_process_add_arg (comm->process, new_filename2);
      fr_process_add_arg (comm->process, comm->filename);
      fr_process_end_command (comm->process);
   }
   g_free(new_filename);
   g_free(new_filename2);
}
Exemplo n.º 27
0
static void
fr_command_arj_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, "arj");

	if (junk_paths)
		fr_process_add_arg (comm->process, "e");
	else
		fr_process_add_arg (comm->process, "x");

	if (dest_dir != NULL)
		fr_process_add_arg_concat (comm->process, "-ht/", dest_dir, NULL);

	if (! overwrite)
		fr_process_add_arg (comm->process, "-n");

	if (skip_older)
		fr_process_add_arg (comm->process, "-u");

	if (comm->password != NULL)
		fr_process_add_arg_concat (comm->process, "-g/", comm->password, NULL);
	else
 		fr_process_add_arg (comm->process, "-g/");

	fr_process_add_arg (comm->process, "-i");
	fr_process_add_arg (comm->process, "-y");
	fr_process_add_arg (comm->process, "-");

	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_unstuff_extract (FrCommand  *comm,
			    const char  *from_file,
			    GList      *file_list,
			    const char *dest_dir,
			    gboolean    overwrite,
			    gboolean    skip_older,
			    gboolean    junk_paths)
{
#if 0
	GList *scan;
#endif
	char  *filename;

	fr_process_begin_command (comm->process, "unstuff");

	if (dest_dir != NULL) {
		char *dest_dir_dots;
		char *arg;

		dest_dir_dots = unstuff_is_shit_with_filenames (dest_dir);
		arg = g_strdup_printf ("-d=%s", dest_dir_dots);
		fr_process_add_arg (comm->process, arg);
		FR_COMMAND_UNSTUFF (comm)->target_dir = NULL;
		g_free (arg);
		g_free (dest_dir_dots);
	}

	fr_process_add_arg (comm->process, "--trace");

	/* unstuff doesn't like file paths starting with /, that's so s***e */
	filename = unstuff_is_shit_with_filenames (comm->filename);
	fr_process_add_arg (comm->process, filename);
	g_free (filename);

	/* FIXME it is not possible to unpack only some files */
#if 0
	for (scan = file_list; scan; scan = scan->next)
		fr_process_add_arg (comm->process, scan->data);
#endif

	fr_process_end_command (comm->process);
}
static gboolean
fr_command_unarchiver_list (FrCommand  *comm)
{
	FrCommandUnarchiver *unar_comm = FR_COMMAND_UNARCHIVER (comm);

	_g_object_unref (unar_comm->stream);
	unar_comm->stream = g_memory_input_stream_new ();

	fr_process_set_out_line_func (comm->process, process_line, comm);

	fr_process_begin_command (comm->process, "lsar");
	fr_process_set_end_func (comm->process, list_command_completed, comm);
	fr_process_add_arg (comm->process, "-j");
	if ((FR_ARCHIVE (comm)->password != NULL) && (FR_ARCHIVE (comm)->password[0] != '\0'))
		fr_process_add_arg_concat (comm->process, "-password=", FR_ARCHIVE (comm)->password, NULL);
	fr_process_add_arg (comm->process, comm->filename);
	fr_process_end_command (comm->process);

	return TRUE;
}
Exemplo n.º 30
0
static void
fr_command_cpio_list (FrCommand  *comm)
{
	fr_process_set_out_line_func (comm->process, list__process_line, comm);

	fr_process_begin_command (comm->process, "sh");
	fr_process_add_arg (comm->process, "-c");
	fr_process_add_arg_concat (comm->process, "cpio -itv < ", comm->e_filename, NULL);
	fr_process_end_command (comm->process);
	fr_process_start (comm->process);
}