Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01NQRTGoYgnZQsh7uCh6Jsxm
36 lines
1014 B
Diff
36 lines
1014 B
Diff
diff --git a/utils/file.c b/utils/file.c
|
|
index 75a8a1c03..a8ab70f67 100644
|
|
--- a/utils/file.c
|
|
+++ b/utils/file.c
|
|
@@ -152,6 +152,30 @@ static nserror posix_nsurl_to_path(struct nsurl *url, char **path_out)
|
|
return res;
|
|
}
|
|
|
|
+#if defined(__montauk__)
|
|
+ /*
|
|
+ * MontaukOS absolute paths are drive-qualified ("0:/dir/file"). The
|
|
+ * file: URL syntax requires a leading slash before the path, so the
|
|
+ * round trip through path_to_nsurl() yields "/0%3A/dir/file", which
|
|
+ * unescapes to "/0:/dir/file". Resolving that treats the leading slash
|
|
+ * as "root of the current drive" and leaves the drive prefix as a
|
|
+ * directory name, producing "0:/0:/dir/file".
|
|
+ *
|
|
+ * Drop the slash when what follows is a drive prefix, restoring the
|
|
+ * original path.
|
|
+ */
|
|
+ if (path[0] == '/') {
|
|
+ const char *p = path + 1;
|
|
+
|
|
+ while (*p >= '0' && *p <= '9') {
|
|
+ p++;
|
|
+ }
|
|
+ if ((p > path + 1) && (*p == ':')) {
|
|
+ memmove(path, path + 1, strlen(path));
|
|
+ }
|
|
+ }
|
|
+#endif
|
|
+
|
|
*path_out = path;
|
|
|
|
return NSERROR_OK;
|