Mercurial > repos > blastem
comparison paths.c @ 1481:77a401044935 nuklear_ui
Fix directory navigation in ROM file chooser in Nuklear UI
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Sat, 25 Nov 2017 13:57:38 -0800 |
parents | 152a60c6787e |
children | 637fbc3b5063 |
comparison
equal
deleted
inserted
replaced
1480:8464a3f09b94 | 1481:77a401044935 |
---|---|
99 tern_node *vars = tern_insert_ptr(NULL, "HOME", get_home_dir()); | 99 tern_node *vars = tern_insert_ptr(NULL, "HOME", get_home_dir()); |
100 vars = tern_insert_ptr(vars, "EXEDIR", get_exe_dir()); | 100 vars = tern_insert_ptr(vars, "EXEDIR", get_exe_dir()); |
101 *dst = replace_vars(*dst, vars, 1); | 101 *dst = replace_vars(*dst, vars, 1); |
102 tern_free(vars); | 102 tern_free(vars); |
103 } | 103 } |
104 | |
105 char *path_append(char *base, char *suffix) | |
106 { | |
107 if (!strcmp(suffix, "..")) { | |
108 #ifdef _WIN32 | |
109 //handle transition from root of a drive to virtual root | |
110 if (base[1] == ':' && !base[2]) { | |
111 return strdup(PATH_SEP) | |
112 } | |
113 #endif | |
114 size_t len = strlen(base); | |
115 while (len > 0) { | |
116 --len; | |
117 if (is_path_sep(base[len])) { | |
118 if (!len) { | |
119 //special handling for / | |
120 len++; | |
121 } | |
122 char *ret = malloc(len+1); | |
123 memcpy(ret, base, len); | |
124 ret[len] = 0; | |
125 return ret; | |
126 } | |
127 } | |
128 return strdup(PATH_SEP); | |
129 } else { | |
130 #ifdef _WIN32 | |
131 if (base[0] == PATH_SEP[0] && !base[1]) { | |
132 //handle transition from virtual root to root of a drive | |
133 return strdup(suffix); | |
134 } | |
135 #endif | |
136 if (is_path_sep(base[strlen(base) - 1])) { | |
137 return alloc_concat(base, suffix); | |
138 } else { | |
139 char const *pieces[] = {base, PATH_SEP, suffix}; | |
140 return alloc_concat_m(3, pieces); | |
141 } | |
142 } | |
143 } |