aboutsummaryrefslogtreecommitdiffstats
path: root/Alc
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2016-04-07 02:59:26 -0700
committerChris Robinson <[email protected]>2016-04-07 02:59:26 -0700
commitf7efa0aff74d50abd4329a110c452de292f1e1c8 (patch)
treef56eb29500c8bdcede41711ff0d24b66faf6a514 /Alc
parente127072b41d64cd95f72572fe897fa8ec2f98ece (diff)
Avoid double slashes when constructing paths
Diffstat (limited to 'Alc')
-rw-r--r--Alc/helpers.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/Alc/helpers.c b/Alc/helpers.c
index c8983c11..47851cf9 100644
--- a/Alc/helpers.c
+++ b/Alc/helpers.c
@@ -620,7 +620,8 @@ static void DirectorySearch(const char *path, const char *ext, vector_al_string
AL_STRING_INIT(str);
al_string_copy_cstr(&str, path);
- al_string_append_char(&str, '/');
+ if(VECTOR_BACK(str) != '/')
+ al_string_append_char(&str, '/');
al_string_append_cstr(&str, dirent->d_name);
TRACE("Got result %s\n", al_string_get_cstr(str));
VECTOR_PUSH_BACK(*results, str);
@@ -661,13 +662,19 @@ vector_al_string SearchDataFiles(const char *ext, const char *subdir)
if((str=getenv("XDG_DATA_HOME")) != NULL && str[0] != '\0')
{
al_string_copy_cstr(&path, str);
- al_string_append_char(&path, '/');
+ if(VECTOR_BACK(path) != '/')
+ al_string_append_char(&path, '/');
al_string_append_cstr(&path, subdir);
DirectorySearch(al_string_get_cstr(path), ext, &results);
}
else if((str=getenv("HOME")) != NULL && str[0] != '\0')
{
al_string_copy_cstr(&path, str);
+ if(VECTOR_BACK(path) == '/')
+ {
+ VECTOR_POP_BACK(path);
+ *VECTOR_ITER_END(path) = 0;
+ }
al_string_append_cstr(&path, "/.local/share/");
al_string_append_cstr(&path, subdir);
DirectorySearch(al_string_get_cstr(path), ext, &results);
@@ -690,7 +697,8 @@ vector_al_string SearchDataFiles(const char *ext, const char *subdir)
}
if(!al_string_empty(path))
{
- al_string_append_char(&path, '/');
+ if(VECTOR_BACK(path) != '/')
+ al_string_append_char(&path, '/');
al_string_append_cstr(&path, subdir);
DirectorySearch(al_string_get_cstr(path), ext, &results);