1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115
|
/*
* 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 Library 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <config.h>
#include <stdlib.h>
#include <glib.h>
#include <glib-object.h>
#include <thunar-vfs/thunar-vfs.h>
#include "libsqueeze-archive.h"
#include "libsqueeze-view.h"
#include "libsqueeze-module.h"
#include "archive-iter.h"
#include "archive-command.h"
#include "archive.h"
#include "command-builder.h"
#include "internals.h"
#define __USE_GNU
#include <unistd.h>
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <sys/wait.h>
static gint
lsq_opened_archives_lookup_archive(gconstpointer open_archive, gconstpointer path);
gchar *
lsq_concat_filenames(GSList *filenames)
{
GSList *_filenames = filenames;
gchar *concat_str = g_strdup(" "), *_concat_str;
while(_filenames)
{
_concat_str = concat_str;
concat_str = g_strconcat(concat_str, " ", g_shell_quote(_filenames->data) , NULL);
_filenames = _filenames->next;
g_free(_concat_str);
}
return concat_str;
}
gchar *
lsq_concat_iter_filenames(GSList *file_iters)
{
GSList *_file_iters = file_iters;
gchar *concat_str = g_strdup(" "), *_concat_str;
while(_file_iters)
{
gchar *path = lsq_archive_iter_get_path(_file_iters->data);
_concat_str = concat_str;
concat_str = g_strconcat(_concat_str, " ", g_shell_quote(path) , NULL);
_file_iters = _file_iters->next;
g_free(_concat_str);
g_free(path);
}
return concat_str;
}
LSQArchive *
lsq_opened_archive_get_archive(gchar *path)
{
GSList *result = g_slist_find_custom(lsq_opened_archive_list, path, lsq_opened_archives_lookup_archive);
if(result)
{
g_object_ref(result->data);
return result->data;
}
return NULL;
}
static gint
lsq_opened_archives_lookup_archive(gconstpointer open_archive, gconstpointer path)
{
#ifdef DEBUG
g_return_val_if_fail(open_archive, 1);
#endif
ThunarVfsPath *path_info = NULL;
if(g_path_is_absolute(path))
path_info = thunar_vfs_path_new(path, NULL);
else
path_info = thunar_vfs_path_relative(lsq_relative_base_path, path);
if(thunar_vfs_path_equal(((LSQArchive *)open_archive)->path_info, path_info))
{
if(path_info)
thunar_vfs_path_unref(path_info);
return 0;
}
else
{
if(path_info)
thunar_vfs_path_unref(path_info);
return 1;
}
}
|