Пример #1
0
void xa_7zip_delete (XArchive *archive,GSList *names)
{
	gchar *command,*exe,*e_filename = NULL;
	GSList *list = NULL,*_names;
	GString *files = g_string_new("");

	if (sevenzr)
		exe = "7zr d ";
	if (sevenza)
		exe = "7za d ";

 	_names = names;
 	while (_names)
	{
		e_filename  = xa_escape_filename((gchar*)_names->data,"$'`\"\\!?* ()[]&|:;<>#");
		g_string_prepend (files,e_filename);
		g_string_prepend_c (files,' ');
		_names = _names->next;
	}
	g_slist_foreach(names,(GFunc)g_free,NULL);
	g_slist_free(names);
	command = g_strconcat (exe,archive->escaped_path," ",files->str,NULL);
	g_string_free(files,TRUE);
	list = g_slist_append(list,command);

	xa_run_command (archive,list);
	if (archive->status == XA_ARCHIVESTATUS_DELETE)
		xa_reload_archive_content(archive);
}
Пример #2
0
void xa_tar_delete (XArchive *archive,GSList *files)
{
	gchar *e_filename,*command = NULL;
	GSList *_files,*list = NULL;
	GString *names = g_string_new("");

	_files = files;
	while (_files)
	{
		e_filename  = xa_escape_filename((gchar*)_files->data,"$'`\"\\!?* ()[]&|:;<>#");
		g_string_prepend (names,e_filename);
		g_string_prepend_c (names,' ');
		_files = _files->next;
	}
	g_slist_foreach(files,(GFunc)g_free,NULL);
	g_slist_free(files);

	if (is_tar_compressed(archive->type))
		xa_add_delete_bzip2_gzip_lzma_compressed_tar(names,archive,0);
	else
	{
		command = g_strconcat (tar, " --delete -vf ",archive->escaped_path," ",names->str,NULL);
		list = g_slist_append(list,command);
		xa_run_command (archive,list);
		if (archive->status == XA_ARCHIVESTATUS_DELETE)
			xa_reload_archive_content(archive);
	}
}
Пример #3
0
void xa_arj_add (XArchive *archive,GString *files,gchar *compression_string)
{
	GSList *list = NULL;
	gchar *command = NULL;

	if (archive->location_entry_path != NULL)
		archive->working_dir = g_strdup(archive->tmp);

	if (compression_string == NULL)
		compression_string = "1";
	if (archive->passwd != NULL)
		command = g_strconcat ( "arj a ",
								archive->update ? "-u " : "",
								archive->freshen ? "-f " : "",
								archive->remove_files ? "-d1 " : "",
								"-g" , archive->passwd , " -i ",
								"-m",compression_string," ",
								archive->escaped_path,files->str,NULL);
	else
		command = g_strconcat ( "arj a ",
								archive->update ? "-u " : "",
								archive->freshen ? "-f " : "",
								archive->remove_files ? "-d1 " : "",
								" -i ",
								"-m",compression_string," ",
								archive->escaped_path,files->str,NULL);
	g_string_free(files,TRUE);
	list = g_slist_append(list,command);

	xa_run_command (archive,list);
	xa_reload_archive_content(archive);
}
Пример #4
0
void xa_7zip_add (XArchive *archive,GString *files,gchar *compression_string)
{
	GSList *list = NULL;
	gchar *command,*exe = NULL;

	if (sevenzr)
		exe = "7zr ";
	if (sevenza)
		exe = "7za ";

	if (archive->location_entry_path != NULL)
		archive->working_dir = g_strdup(archive->tmp);

	if (compression_string == NULL)
		compression_string = "5";
	if (archive->passwd != NULL)
		command = g_strconcat ( exe,
								archive->update ? "u " : "a ",
								archive->solid_archive ? "-ms=on " : "-ms=off ",
								"-p" , archive->passwd, " ",
								archive->escaped_path," ",
								"-mx=",compression_string,"",
								files->str,NULL);
	else
		command = g_strconcat ( exe,
								archive->update ? "u " : "a ",
								archive->solid_archive ? "-ms=on " : "-ms=off ",
								archive->escaped_path," ",
								"-mx=",compression_string,"",
								files->str,NULL);
	g_string_free(files,TRUE);
	list = g_slist_append(list,command);

	xa_run_command (archive,list);
	xa_reload_archive_content(archive);
}
Пример #5
0
void xa_add_delete_bzip2_gzip_lzma_compressed_tar (GString *files,XArchive *archive,gboolean add)
{
	gchar *command,*executable = NULL,*filename = NULL;
	gboolean result;
	GSList *list = NULL;
	
	switch (archive->type)
	{
		case XARCHIVETYPE_TAR_BZ2:
			executable = "bzip2 -f ";
			filename = "dummy.bz2";
		break;
		case XARCHIVETYPE_TAR_GZ:
			executable = "gzip -f ";
			filename = "dummy.gz";
		break;
		case XARCHIVETYPE_TAR_LZMA:
			executable = "lzma -f ";
			filename = "dummy.lzma";
		break;
		case XARCHIVETYPE_TAR_LZOP:
			executable = "lzop -f ";
			filename = "dummy.lzo";
		break;
		
		default:
		break;
	}
	/* Let's copy the archive to /tmp first */
	result = xa_create_temp_directory(archive);
	if (!result)
		return;

	/* Let's copy the archive to /tmp first */
	command = g_strconcat ("cp -a ",archive->escaped_path," ",archive->tmp,"/",filename,NULL);
	list = g_slist_append(list,command);

	command = g_strconcat (executable,"-d ",archive->tmp,"/",filename,NULL);
	list = g_slist_append(list,command);

	if (add)
		command = g_strconcat (tar, " ",
							archive->add_recurse ? "" : "--no-recursion ",
							archive->remove_files ? "--remove-files " : "",
							archive->update ? "-uvvf " : "-rvvf ",
							archive->tmp,"/dummy",
							files->str , NULL );
	else
		command = g_strconcat (tar," --no-wildcards --delete -f ",archive->tmp,"/dummy ",files->str,NULL);
	list = g_slist_append(list,command);

	command = g_strconcat (executable,archive->tmp,"/dummy",NULL);
	list = g_slist_append(list,command);

	/* Let's move the modified archive from /tmp to the original archive location */
	command = g_strconcat ("mv ",archive->tmp,"/",filename," ",archive->escaped_path,NULL);
	list = g_slist_append(list,command);
	xa_run_command (archive,list);
	if (archive->status == XA_ARCHIVESTATUS_DELETE || archive->status == XA_ARCHIVESTATUS_ADD)
		xa_reload_archive_content(archive);
}
Пример #6
0
void xa_tar_add (XArchive *archive,GString *files,gchar *compression_string)
{
	GSList *list = NULL;
	gchar *command = NULL;

	if (archive->location_entry_path != NULL)
		archive->working_dir = g_strdup(archive->tmp);

	switch (archive->type)
	{
		case XARCHIVETYPE_TAR:
		if ( g_file_test (archive->escaped_path,G_FILE_TEST_EXISTS))
			command = g_strconcat (tar, " ",
									archive->add_recurse ? "" : "--no-recursion ",
									archive->remove_files ? "--remove-files " : "",
									archive->update ? "-uvvf " : "-rvvf ",
									archive->escaped_path,
									files->str , NULL );
		else
			command = g_strconcat (tar, " ",
									archive->add_recurse ? "" : "--no-recursion ",
									archive->remove_files ? "--remove-files " : "",
									"-cvvf ",archive->escaped_path,
									files->str , NULL );
		break;

		case XARCHIVETYPE_TAR_BZ2:
		if ( g_file_test ( archive->escaped_path , G_FILE_TEST_EXISTS ) )
			xa_add_delete_bzip2_gzip_lzma_compressed_tar (files,archive,1);
		else
			command = g_strconcat (tar, " ",
									archive->add_recurse ? "" : "--no-recursion ",
									archive->remove_files ? "--remove-files " : "",
									"-cvvjf ",archive->escaped_path,
									files->str , NULL );
		break;

		case XARCHIVETYPE_TAR_GZ:
		if ( g_file_test ( archive->escaped_path , G_FILE_TEST_EXISTS ) )
			xa_add_delete_bzip2_gzip_lzma_compressed_tar (files,archive,1);
		else
			command = g_strconcat (tar, " ",
									archive->add_recurse ? "" : "--no-recursion ",
									archive->remove_files ? "--remove-files " : "",
									"-cvvzf ",archive->escaped_path,
									files->str , NULL );
		break;
		
		case XARCHIVETYPE_TAR_LZMA:
		if ( g_file_test ( archive->escaped_path , G_FILE_TEST_EXISTS ) )
			xa_add_delete_bzip2_gzip_lzma_compressed_tar (files,archive,1);
		else
			command = g_strconcat (tar, " ",
									archive->add_recurse ? "" : "--no-recursion ",
									archive->remove_files ? "--remove-files " : "",
									"--use-compress-program=lzma -cvvf ",archive->escaped_path,
									files->str , NULL );
		break;
		
		case XARCHIVETYPE_TAR_LZOP:
		if ( g_file_test ( archive->escaped_path , G_FILE_TEST_EXISTS ) )
			xa_add_delete_bzip2_gzip_lzma_compressed_tar (files,archive,1);
		else
			command = g_strconcat (tar, " ",
									archive->add_recurse ? "" : "--no-recursion ",
									archive->remove_files ? "--remove-files " : "",
									"--use-compress-program=lzop -cvvf ",archive->escaped_path,
									files->str , NULL );
		break;

		case XARCHIVETYPE_BZIP2:
			command = g_strconcat("sh -c \"bzip2 -c ",files->str,"> ",archive->escaped_path,"\"",NULL);
		break;

		case XARCHIVETYPE_GZIP:
			command = g_strconcat("sh -c \"gzip -c ",files->str,"> ",archive->escaped_path,"\"",NULL);
		break;

		case XARCHIVETYPE_LZMA:
			command = g_strconcat("sh -c \"lzma -c ",files->str,"> ",archive->escaped_path,"\"",NULL);
		break;

		case XARCHIVETYPE_LZOP:
			command = g_strconcat("sh -c \"lzop -c ",files->str,"> ",archive->escaped_path,"\"",NULL);
		break;

		default:
		command = NULL;
	}

	if (command != NULL)
	{
		g_string_free(files,TRUE);
		list = g_slist_append(list,command);
		xa_run_command (archive,list);
		xa_reload_archive_content(archive);
	}
}