don't print .. at sandbox top level
This commit is contained in:
parent
245ba17115
commit
57dfcdf717
|
@ -82,6 +82,17 @@ file_read_dir(UxnFile *c, char *dest, Uint16 len)
|
||||||
Uint16 n;
|
Uint16 n;
|
||||||
if(c->de->d_name[0] == '.' && c->de->d_name[1] == '\0')
|
if(c->de->d_name[0] == '.' && c->de->d_name[1] == '\0')
|
||||||
continue;
|
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))
|
if(strlen(c->current_filename) + 1 + strlen(c->de->d_name) < sizeof(pathname))
|
||||||
sprintf(pathname, "%s/%s", c->current_filename, c->de->d_name);
|
sprintf(pathname, "%s/%s", c->current_filename, c->de->d_name);
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in New Issue