diff options
author | hiro <hiro@ee746299-78ed-0310-b773-934348b2243d> | 2009-12-17 02:51:57 +0000 |
---|---|---|
committer | hiro <hiro@ee746299-78ed-0310-b773-934348b2243d> | 2009-12-17 02:51:57 +0000 |
commit | d5175b3fc5fda02558b7754ba160eee360ccb7ec (patch) | |
tree | ae491e12e7e2c1b3e88127db4e438d598698e36e /libsylph/utils.c | |
parent | 5fb2905b9f6c975ef03240393363471c81c1e21d (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.c | 27 |
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) { |