Mercurial > repos > blastem
comparison menu.c @ 1024:5ebf6ddd5a44
Allow navigating to the root directory on Unix-like systems
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Wed, 04 May 2016 22:11:48 -0700 |
parents | 6c54d5a5c7c0 |
children | 2c8d76280e43 |
comparison
equal
deleted
inserted
replaced
1023:f1fd9263ccec | 1024:5ebf6ddd5a44 |
---|---|
191 case 1: { | 191 case 1: { |
192 char buf[4096]; | 192 char buf[4096]; |
193 copy_string_from_guest(m68k, dst, buf, sizeof(buf)); | 193 copy_string_from_guest(m68k, dst, buf, sizeof(buf)); |
194 if (!strcmp(buf, "..")) { | 194 if (!strcmp(buf, "..")) { |
195 size_t len = strlen(menu->curpath); | 195 size_t len = strlen(menu->curpath); |
196 while (len > 1) { | 196 while (len > 0) { |
197 --len; | 197 --len; |
198 if (is_path_sep(menu->curpath[len])) { | 198 if (is_path_sep(menu->curpath[len])) { |
199 menu->curpath[len] = 0; | 199 if (!len) { |
200 //special handling for / | |
201 menu->curpath[len+1] = 0; | |
202 } else { | |
203 menu->curpath[len] = 0; | |
204 } | |
200 break; | 205 break; |
201 } | 206 } |
202 } | 207 } |
203 } else { | 208 } else { |
204 char *tmp = menu->curpath; | 209 char *tmp = menu->curpath; |
205 char const *pieces[] = {menu->curpath, PATH_SEP, buf}; | 210 if (is_path_sep(menu->curpath[strlen(menu->curpath) - 1])) { |
206 menu->curpath = alloc_concat_m(3, pieces); | 211 menu->curpath = alloc_concat(menu->curpath, buf); |
212 } else { | |
213 char const *pieces[] = {menu->curpath, PATH_SEP, buf}; | |
214 menu->curpath = alloc_concat_m(3, pieces); | |
215 } | |
207 free(tmp); | 216 free(tmp); |
208 } | 217 } |
209 break; | 218 break; |
210 } | 219 } |
211 case 2: { | 220 case 2: { |