summaryrefslogtreecommitdiff
path: root/src/glib-utils.c
diff options
context:
space:
mode:
authorraveit65 <[email protected]>2015-10-14 20:23:41 +0200
committerraveit65 <[email protected]>2015-10-14 20:23:41 +0200
commitd905fba84d8a21491c368b7a78cd8a064954ffe7 (patch)
treebc9df1d33151a284a65024dfb41f4c54b0bd153c /src/glib-utils.c
parentef693f552dfb377625f4dc6b739846e3a5312394 (diff)
downloadengrampa-d905fba84d8a21491c368b7a78cd8a064954ffe7.tar.bz2
engrampa-d905fba84d8a21491c368b7a78cd8a064954ffe7.tar.xz
fixed overwrite check when the files to be extracted are inside a folder
author ZenWalker <[email protected]> fixes https://github.com/mate-desktop/engrampa/issues/103
Diffstat (limited to 'src/glib-utils.c')
-rw-r--r--src/glib-utils.c48
1 files changed, 48 insertions, 0 deletions
diff --git a/src/glib-utils.c b/src/glib-utils.c
index 669499b..9761091 100644
--- a/src/glib-utils.c
+++ b/src/glib-utils.c
@@ -713,3 +713,51 @@ _g_strv_remove (char **str_array,
return TRUE;
}
+
+const gchar *
+_g_path_get_file_name (const gchar *file_name)
+{
+ register char *base;
+ register gssize last_char;
+
+ if (file_name == NULL)
+ return NULL;
+
+ if (file_name[0] == '\0')
+ return "";
+
+ last_char = strlen (file_name) - 1;
+
+ if (file_name [last_char] == G_DIR_SEPARATOR)
+ return "";
+
+ base = g_utf8_strrchr (file_name, -1, G_DIR_SEPARATOR);
+ if (! base)
+ return file_name;
+
+ return base + 1;
+}
+
+
+const char *
+_g_path_get_base_name (const char *path,
+ const char *base_dir,
+ gboolean junk_paths)
+{
+ int base_dir_len;
+ const char *base_path;
+
+ if (junk_paths)
+ return _g_path_get_file_name (path);
+
+ base_dir_len = strlen (base_dir);
+ if (strlen (path) <= base_dir_len)
+ return NULL;
+
+ base_path = path + base_dir_len;
+ if (path[0] != '/')
+ base_path -= 1;
+
+ return base_path;
+}
+