fix: fix ramdisk readdir inconsistency.
This commit is contained in:
@@ -269,8 +269,8 @@ void filemanager_read_dir(FileManagerState* fm) {
|
||||
fm->virtual_view = FM_VIRTUAL_VIEW_NONE;
|
||||
fm->entry_count = 0;
|
||||
|
||||
// readdir returns full paths from the VFS (e.g. "man/fetch.1" instead
|
||||
// of just "fetch.1"). Compute the prefix to strip so we get basenames.
|
||||
// Current drivers return direct-child names. Retain prefix stripping for
|
||||
// compatibility with images built against the older ramdisk behavior.
|
||||
const char* after_drive = fm->current_path;
|
||||
for (int k = 0; after_drive[k]; k++) {
|
||||
if (after_drive[k] == ':' && after_drive[k + 1] == '/') {
|
||||
@@ -433,7 +433,7 @@ void filemanager_read_system_configuration(FileManagerState* fm) {
|
||||
static int filemanager_read_all_children(const char* dir, char (**out)[256]) {
|
||||
*out = nullptr;
|
||||
|
||||
// Compute the prefix to strip (readdir returns drive-root-relative paths).
|
||||
// Retain support for older ramdisks that returned drive-root-relative paths.
|
||||
const char* after_drive = dir;
|
||||
for (int k = 0; after_drive[k]; k++) {
|
||||
if (after_drive[k] == ':' && after_drive[k + 1] == '/') {
|
||||
|
||||
@@ -14,9 +14,8 @@
|
||||
// App Manifest Scanning
|
||||
// ============================================================================
|
||||
|
||||
// Extract the basename from a readdir entry.
|
||||
// readdir returns full paths from drive root (e.g. "apps/doom/") —
|
||||
// strip the directory prefix and any trailing slash to get just "doom".
|
||||
// Extract the basename from a readdir entry, tolerating both current
|
||||
// direct-child names and paths returned by older ramdisk kernels.
|
||||
static void extract_basename(char* out, int outSz, const char* entry) {
|
||||
// Strip trailing slash
|
||||
int len = montauk::slen(entry);
|
||||
@@ -89,7 +88,7 @@ void desktop_scan_apps(DesktopState* ds) {
|
||||
scanned += got;
|
||||
|
||||
for (int i = 0; i < got; i++) {
|
||||
// readdir returns paths like "apps/doom/" — extract just "doom"
|
||||
// Strip the directory marker and tolerate old root-relative entries.
|
||||
char dirname[64];
|
||||
extract_basename(dirname, sizeof(dirname), entries[i]);
|
||||
if (dirname[0] == '\0') continue;
|
||||
|
||||
@@ -258,7 +258,7 @@ inline void wallpaper_scan_dir(const char* dir_path, WallpaperFileList* list,
|
||||
int total = montauk::readdir(dir_path, raw_names, 64);
|
||||
if (total <= 0) return;
|
||||
|
||||
// Compute prefix to strip (readdir returns full paths from VFS root)
|
||||
// Retain support for older ramdisks that returned paths from the VFS root.
|
||||
const char* after_drive = dir_path;
|
||||
for (int k = 0; after_drive[k]; k++) {
|
||||
if (after_drive[k] == ':' && after_drive[k + 1] == '/') {
|
||||
|
||||
Reference in New Issue
Block a user