diff --git a/src/devices/file.c b/src/devices/file.c index dbcb1a1..87cf9a2 100644 --- a/src/devices/file.c +++ b/src/devices/file.c @@ -82,6 +82,17 @@ file_read_dir(UxnFile *c, char *dest, Uint16 len) Uint16 n; if(c->de->d_name[0] == '.' && c->de->d_name[1] == '\0') continue; + if(strcmp(c->de->d_name, "..") == 0) { + /* hide "sandbox/.." */ + char cwd[PATH_MAX] = {'\0'}, t[PATH_MAX] = {'\0'}; + /* Note there's [currently] no way of chdir()ing from uxn, so $PWD + * is always the sandbox top level. */ + getcwd(cwd, sizeof(cwd)); + /* We already checked that c->current_filename exists so don't need a wrapper. */ + realpath(c->current_filename, t); + if (strcmp(cwd, t) == 0) + continue; + } if(strlen(c->current_filename) + 1 + strlen(c->de->d_name) < sizeof(pathname)) sprintf(pathname, "%s/%s", c->current_filename, c->de->d_name); else