aboutsummaryrefslogtreecommitdiff
path: root/libsylph/utils.c
diff options
context:
space:
mode:
authorhiro <hiro@ee746299-78ed-0310-b773-934348b2243d>2009-12-17 02:51:57 +0000
committerhiro <hiro@ee746299-78ed-0310-b773-934348b2243d>2009-12-17 02:51:57 +0000
commitd5175b3fc5fda02558b7754ba160eee360ccb7ec (patch)
treeae491e12e7e2c1b3e88127db4e438d598698e36e /libsylph/utils.c
parent5fb2905b9f6c975ef03240393363471c81c1e21d (diff)
src/setup.c: check whether the specified location includes settings folder.
git-svn-id: svn://sylpheed.sraoss.jp/sylpheed/trunk@2398 ee746299-78ed-0310-b773-934348b2243d
Diffstat (limited to 'libsylph/utils.c')
-rw-r--r--libsylph/utils.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/libsylph/utils.c b/libsylph/utils.c
index 88b2fafb..3a14e690 100644
--- a/libsylph/utils.c
+++ b/libsylph/utils.c
@@ -392,6 +392,33 @@ gint path_cmp(const gchar *s1, const gchar *s2)
#endif
}
+/* return TRUE if parent is equal to or ancestor of child */
+gboolean is_path_parent(const gchar *parent, const gchar *child)
+{
+ gint plen;
+ const gchar *base;
+
+ g_return_val_if_fail(parent != NULL, FALSE);
+ g_return_val_if_fail(child != NULL, FALSE);
+
+ plen = strlen(parent);
+ while (plen > 0 && G_IS_DIR_SEPARATOR(parent[plen - 1]))
+ plen--;
+
+#ifdef G_OS_WIN32
+ if (!g_ascii_strncasecmp(parent, child, plen)) {
+#else
+ if (!strncmp(parent, child, plen)) {
+#endif
+ base = child + plen;
+ if (!G_IS_DIR_SEPARATOR(*base) && *base != '\0')
+ return FALSE;
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
/* remove trailing return code */
gchar *strretchomp(gchar *str)
{