file-roller r2287 - in trunk: . src
- From: paobac svn gnome org
- To: svn-commits-list gnome org
- Subject: file-roller r2287 - in trunk: . src
- Date: Mon, 2 Jun 2008 12:28:04 +0000 (UTC)
Author: paobac
Date: Mon Jun 2 12:28:04 2008
New Revision: 2287
URL: http://svn.gnome.org/viewvc/file-roller?rev=2287&view=rev
Log:
2008-06-02 Paolo Bacchilega <paobac svn gnome org>
* src/glib-utils.h:
* src/glib-utils.c:
new functions: g_str_starts_with, g_str_ends_with
* src/fr-window.c:
* src/fr-command-jar.c:
* src/file-utils.h:
* src/file-utils.c:
* src/dlg-add-folder.c:
use the custom build_uri function instead of g_buid_path.
* src/fr-archive.c (get_extract_here_destination):
init the error to NULL
Modified:
trunk/ChangeLog
trunk/src/dlg-add-folder.c
trunk/src/file-utils.c
trunk/src/file-utils.h
trunk/src/fr-archive.c
trunk/src/fr-command-jar.c
trunk/src/fr-window.c
trunk/src/glib-utils.c
trunk/src/glib-utils.h
Modified: trunk/src/dlg-add-folder.c
==============================================================================
--- trunk/src/dlg-add-folder.c (original)
+++ trunk/src/dlg-add-folder.c Mon Jun 2 12:28:04 2008
@@ -169,10 +169,9 @@
if (utf8_only_spaces (exclude_folders))
exclude_folders = NULL;
- dest_uri = g_build_path (G_DIR_SEPARATOR_S,
- fr_window_get_current_location (window),
- file_name_from_path (folder),
- NULL);
+ dest_uri = build_uri (fr_window_get_current_location (window),
+ file_name_from_path (folder),
+ NULL);
dest_dir = g_filename_from_uri (dest_uri, NULL, NULL);
fr_window_archive_add_with_wildcard (window,
Modified: trunk/src/file-utils.c
==============================================================================
--- trunk/src/file-utils.c (original)
+++ trunk/src/file-utils.c Mon Jun 2 12:28:04 2008
@@ -253,7 +253,7 @@
break;
}
- content_uri = g_build_path (uri, name, NULL);
+ content_uri = build_uri (uri, name, NULL);
g_object_unref (info);
}
@@ -473,6 +473,43 @@
}
+char *
+remove_ending_separator (const char *path)
+{
+ gint len, copy_len;
+
+ if (path == NULL)
+ return NULL;
+
+ copy_len = len = strlen (path);
+ if ((len > 1) && (path[len - 1] == '/'))
+ copy_len--;
+
+ return g_strndup (path, copy_len);
+}
+
+
+char *
+build_uri (const char *base, ...)
+{
+ va_list args;
+ const char *child;
+ GString *uri;
+
+ uri = g_string_new (base);
+
+ va_start (args, base);
+ while ((child = va_arg (args, const char *)) != NULL) {
+ if (! g_str_ends_with (uri->str, "/") && ! g_str_starts_with (child, "/"))
+ g_string_append (uri, "/");
+ g_string_append (uri, child);
+ }
+ va_end (args);
+
+ return g_string_free (uri, FALSE);
+}
+
+
gchar *
remove_extension_from_path (const gchar *path)
{
@@ -499,22 +536,6 @@
}
-char *
-remove_ending_separator (const char *path)
-{
- gint len, copy_len;
-
- if (path == NULL)
- return NULL;
-
- copy_len = len = strlen (path);
- if ((len > 1) && (path[len - 1] == '/'))
- copy_len--;
-
- return g_strndup (path, copy_len);
-}
-
-
gboolean
make_directory_tree (GFile *dir,
mode_t mode,
@@ -760,7 +781,7 @@
char *child_uri;
GFile *child;
- child_uri = g_build_path ("/", uri, g_file_info_get_name (info), NULL);
+ child_uri = build_uri (uri, g_file_info_get_name (info), NULL);
child = g_file_new_for_uri (child_uri);
switch (g_file_info_get_file_type (info)) {
Modified: trunk/src/file-utils.h
==============================================================================
--- trunk/src/file-utils.h (original)
+++ trunk/src/file-utils.h Mon Jun 2 12:28:04 2008
@@ -64,8 +64,9 @@
G_CONST_RETURN char*file_name_from_path (const char *path);
char * dir_name_from_path (const char *path);
char * remove_level_from_path (const char *path);
-char * remove_extension_from_path (const char *path);
char * remove_ending_separator (const char *path);
+char * build_uri (const char *base, ...);
+char * remove_extension_from_path (const char *path);
const char * get_file_extension (const char *filename);
gboolean file_extension_is (const char *filename,
const char *ext);
Modified: trunk/src/fr-archive.c
==============================================================================
--- trunk/src/fr-archive.c (original)
+++ trunk/src/fr-archive.c Mon Jun 2 12:28:04 2008
@@ -2859,6 +2859,8 @@
desired_destination = get_desired_destination_for_archive (file);
do {
+ *error = NULL;
+
g_free (destination);
if (n == 1)
destination = g_strdup (desired_destination);
@@ -2892,7 +2894,7 @@
const char *password)
{
char *destination;
- GError *error;
+ GError *error = NULL;
destination = get_extract_here_destination (archive->file, &error);
if (error != NULL) {
Modified: trunk/src/fr-command-jar.c
==============================================================================
--- trunk/src/fr-command-jar.c (original)
+++ trunk/src/fr-command-jar.c Mon Jun 2 12:28:04 2008
@@ -63,7 +63,7 @@
for (scan = file_list; scan; scan = scan->next) {
char *filename = scan->data;
- char *path = g_build_path (G_DIR_SEPARATOR_S, base_dir, filename, NULL);
+ char *path = build_uri (base_dir, filename, NULL);
char *package = NULL;
if (file_extension_is (filename, ".java"))
@@ -95,17 +95,13 @@
char *link_name;
int retval;
- pack_path = g_build_path (G_DIR_SEPARATOR_S,
- tmp_dir,
- jdata->package_minus_one_level,
- NULL);
-
+ pack_path = build_uri (tmp_dir, jdata->package_minus_one_level, NULL);
if (! make_directory_tree_from_path (pack_path, 0755, NULL)) {
g_free (pack_path);
continue;
}
- old_link = g_build_path (G_DIR_SEPARATOR_S, base_dir, jdata->rel_path, NULL);
+ old_link = build_uri (base_dir, jdata->rel_path, NULL);
link_name = g_build_filename (pack_path, jdata->link_name, NULL);
retval = symlink (old_link, link_name);
Modified: trunk/src/fr-window.c
==============================================================================
--- trunk/src/fr-window.c (original)
+++ trunk/src/fr-window.c Mon Jun 2 12:28:04 2008
@@ -7479,7 +7479,7 @@
g_free (utf8_path);
if (destination[0] != '/')
- current_dir = g_build_path (G_DIR_SEPARATOR_S, fr_window_get_current_location (window), destination, NULL);
+ current_dir = build_uri (fr_window_get_current_location (window), destination, NULL);
else
current_dir = g_strdup (destination);
g_free (destination);
Modified: trunk/src/glib-utils.c
==============================================================================
--- trunk/src/glib-utils.c (original)
+++ trunk/src/glib-utils.c Mon Jun 2 12:28:04 2008
@@ -632,3 +632,20 @@
return result;
}
+
+
+gboolean
+g_str_starts_with (const char *s,
+ const char *c)
+{
+ return strncmp (s, c, strlen (c)) == 0;
+}
+
+
+gboolean
+g_str_ends_with (const char *s,
+ const char *c)
+{
+ int c_len = strlen (c);
+ return strncmp (s + strlen (s) - c_len, c, c_len) == 0;
+}
Modified: trunk/src/glib-utils.h
==============================================================================
--- trunk/src/glib-utils.h (original)
+++ trunk/src/glib-utils.h Mon Jun 2 12:28:04 2008
@@ -67,6 +67,11 @@
void g_ptr_array_reverse (GPtrArray *array);
const char * get_static_string (const char *s);
+gboolean g_str_starts_with (const char *s,
+ const char *c);
+gboolean g_str_ends_with (const char *s,
+ const char *c);
+
/**/
#ifndef __GNUC__
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]