commit 57dfcdf
phoebos
·
2022-07-29 12:06:20 +0000 UTC
parent 245ba17
don't print .. at sandbox top level
1 files changed,
+11,
-0
+11,
-0
1@@ -82,6 +82,17 @@ file_read_dir(UxnFile *c, char *dest, Uint16 len)
2 Uint16 n;
3 if(c->de->d_name[0] == '.' && c->de->d_name[1] == '\0')
4 continue;
5+ if(strcmp(c->de->d_name, "..") == 0) {
6+ /* hide "sandbox/.." */
7+ char cwd[PATH_MAX] = {'\0'}, t[PATH_MAX] = {'\0'};
8+ /* Note there's [currently] no way of chdir()ing from uxn, so $PWD
9+ * is always the sandbox top level. */
10+ getcwd(cwd, sizeof(cwd));
11+ /* We already checked that c->current_filename exists so don't need a wrapper. */
12+ realpath(c->current_filename, t);
13+ if (strcmp(cwd, t) == 0)
14+ continue;
15+ }
16 if(strlen(c->current_filename) + 1 + strlen(c->de->d_name) < sizeof(pathname))
17 sprintf(pathname, "%s/%s", c->current_filename, c->de->d_name);
18 else