[libgxps] Use g_file_resolve_relative_path() instead of our buggy code
- From: Carlos Garcia Campos <carlosgc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgxps] Use g_file_resolve_relative_path() instead of our buggy code
- Date: Mon, 6 Sep 2010 09:26:50 +0000 (UTC)
commit eead70cb1edf8941482891999f65b4b50398a57c
Author: Carlos Garcia Campos <carlosgc gnome org>
Date: Mon Sep 6 11:25:24 2010 +0200
Use g_file_resolve_relative_path() instead of our buggy code
g_file_resolve_relative_path() works even if the path doesn't exist in
the file system, so it works for us.
libgxps/gxps-parse-utils.c | 21 ++++++++-------------
1 files changed, 8 insertions(+), 13 deletions(-)
---
diff --git a/libgxps/gxps-parse-utils.c b/libgxps/gxps-parse-utils.c
index 59e0222..afdff88 100644
--- a/libgxps/gxps-parse-utils.c
+++ b/libgxps/gxps-parse-utils.c
@@ -275,6 +275,8 @@ gchar *
gxps_resolve_relative_path (const gchar *source,
const gchar *target)
{
+ GFile *source_file;
+ GFile *abs_file;
gchar *dirname;
gchar *retval;
@@ -284,20 +286,13 @@ gxps_resolve_relative_path (const gchar *source,
dirname = g_path_get_dirname (source);
if (strlen (dirname) == 1 && dirname[0] == '.')
dirname[0] = '/';
-
- if (strlen (target) >= 2 && target[0] == '.' && target[1] == '.') {
- gchar *parent;
-
- parent = g_path_get_dirname (dirname);
- g_free (dirname);
- dirname = parent;
- target += 2;
- } else if (target[0] == '.') {
- target++;
- }
-
- retval = g_build_filename (dirname, target, NULL);
+ source_file = g_file_new_for_path (dirname);
g_free (dirname);
+ abs_file = g_file_resolve_relative_path (source_file, target);
+ retval = g_file_get_path (abs_file);
+ g_object_unref (abs_file);
+ g_object_unref (source_file);
+
return retval;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]