fix: fix filemanager filename tile rendering, edit cwd

This commit is contained in:
2026-04-06 09:16:37 +02:00
parent 104f442551
commit dd628f9fb2
2 changed files with 59 additions and 16 deletions
+38 -8
View File
@@ -222,17 +222,47 @@ static void set_status(const char* msg) {
// Build VFS path from filename
static void build_path(const char* fname, char* out, int outMax) {
int i = 0;
// Check if already has drive prefix
bool hasPrefix = (fname[0] >= '0' && fname[0] <= '9' && fname[1] == ':');
if (!hasPrefix) {
out[i++] = '0'; out[i++] = ':'; out[i++] = '/';
if (hasPrefix) {
// Absolute path - copy as-is
int i = 0;
while (fname[i] && i < outMax - 1) {
out[i++] = fname[i];
}
out[i] = '\0';
} else {
// Relative path - prepend CWD
char cwd[256];
if (montauk::getcwd(cwd, sizeof(cwd)) > 0) {
int i = 0;
int j = 0;
// Copy CWD
while (cwd[j] && i < outMax - 1) {
out[i++] = cwd[j++];
}
// Ensure we end with /
if (i > 0 && out[i-1] != '/') {
out[i++] = '/';
}
// Append filename
j = 0;
while (fname[j] && i < outMax - 1) {
out[i++] = fname[j++];
}
out[i] = '\0';
} else {
// Fallback: just prepend 0:/
int i = 0;
out[i++] = '0'; out[i++] = ':'; out[i++] = '/';
int j = 0;
while (fname[j] && i < outMax - 1) {
out[i++] = fname[j++];
}
out[i] = '\0';
}
}
int j = 0;
while (fname[j] && i < outMax - 1) {
out[i++] = fname[j++];
}
out[i] = '\0';
}
static void load_file(const char* fname) {