diff options
Diffstat (limited to 'src/gallery-utils.c')
| -rw-r--r-- | src/gallery-utils.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/gallery-utils.c b/src/gallery-utils.c index 2b74b9b..b7593fe 100644 --- a/src/gallery-utils.c +++ b/src/gallery-utils.c @@ -265,3 +265,24 @@ remove_tags (char **str, const char *tag_begin, const char *tag_end) } *str = src; } + +/* + * count_dir_levels: returns number of path elements + */ +int +count_dir_levels (const char* path) +{ + int i; + int level; + + if (path == NULL || strlen (path) == 0) + return 0; + + level = 1; + for (i = strlen (path) - 1; i > 0; i--) { + if (G_IS_DIR_SEPARATOR (*(path + i)) && i > 0 && i < strlen (path)) + level++; + } + + return level; +} |
