fs: fix stdio dir count not filtering types. game/bfsar: fix dir listing loop exiting early due to post increment in the loop.

This commit is contained in:
ITotalJustice
2025-09-27 03:37:29 +01:00
parent 63e11ca377
commit faebc42f0d
3 changed files with 16 additions and 2 deletions

View File

@@ -688,6 +688,20 @@ Result Dir::GetEntryCount(s64* out) {
if (!std::strcmp(d->d_name, ".") || !std::strcmp(d->d_name, "..")) { if (!std::strcmp(d->d_name, ".") || !std::strcmp(d->d_name, "..")) {
continue; continue;
} }
if (d->d_type == DT_DIR) {
if (!(m_mode & FsDirOpenMode_ReadDirs)) {
continue;
}
} else if (d->d_type == DT_REG) {
if (!(m_mode & FsDirOpenMode_ReadFiles)) {
continue;
}
} else {
log_write("[FS] WARNING: unknown type when counting dir: %u\n", d->d_type);
continue;
}
(*out)++; (*out)++;
} }

View File

@@ -215,7 +215,7 @@ int Device::devoptab_dirnext(void* fd, char *filename, struct stat *filestat) {
filestat->st_mode = S_IFREG | S_IRUSR | S_IRGRP | S_IROTH; filestat->st_mode = S_IFREG | S_IRUSR | S_IRGRP | S_IROTH;
dir->index++; dir->index++;
break; break;
} while (dir->index++); } while (++dir->index);
return 0; return 0;
} }

View File

@@ -425,7 +425,7 @@ int Device::devoptab_dirnext(void* fd, char *filename, struct stat *filestat) {
std::snprintf(filename, NAME_MAX, "%s", content.nsp->path.s); std::snprintf(filename, NAME_MAX, "%s", content.nsp->path.s);
dir->index++; dir->index++;
break; break;
} while (dir->index++); } while (++dir->index);
} }
return 0; return 0;