Skip to content

Commit ff76576

Browse files
authored
Fix #6489 (#8548)
* fix #6489 * test * consistent * fix eval
1 parent dbbb9da commit ff76576

File tree

5 files changed

+12
-0
lines changed

5 files changed

+12
-0
lines changed

src/macro/eval/evalStdLib.ml

+1
Original file line numberDiff line numberDiff line change
@@ -1189,6 +1189,7 @@ module StdFileSystem = struct
11891189

11901190
let patch_path s =
11911191
if String.length s > 1 && String.length s <= 3 && s.[1] = ':' then Path.add_trailing_slash s
1192+
else if s = "/" then "/"
11921193
else remove_trailing_slash s
11931194

11941195
let createDirectory = vfun1 (fun path ->

std/cpp/_std/sys/FileSystem.hx

+2
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,8 @@ class FileSystem {
104104
private static inline function makeCompatiblePath(path:String):String {
105105
return if (path.charCodeAt(1) == ":".code && path.length <= 3) {
106106
haxe.io.Path.addTrailingSlash(path);
107+
} else if (path == "/") {
108+
"/";
107109
} else {
108110
haxe.io.Path.removeTrailingSlashes(path);
109111
}

std/hl/_std/sys/FileSystem.hx

+2
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,8 @@ class FileSystem {
102102
private static inline function makeCompatiblePath(path:String):String {
103103
return if (path.charCodeAt(1) == ":".code && path.length <= 3) {
104104
haxe.io.Path.addTrailingSlash(path);
105+
} else if (path == "/") {
106+
"/";
105107
} else {
106108
haxe.io.Path.removeTrailingSlashes(path);
107109
}

std/neko/_std/sys/FileSystem.hx

+2
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,8 @@ class FileSystem {
104104
private static inline function makeCompatiblePath(path:String):String {
105105
return if (path.charCodeAt(1) == ":".code && path.length <= 3) {
106106
haxe.io.Path.addTrailingSlash(path);
107+
} else if (path == "/") {
108+
"/";
107109
} else {
108110
haxe.io.Path.removeTrailingSlashes(path);
109111
}

tests/sys/src/TestFileSystem.hx

+5
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,11 @@ class TestFileSystem extends utest.Test {
9494
}
9595
}
9696

97+
function testRootExists() {
98+
Assert.isTrue(FileSystem.exists("/"));
99+
Assert.isTrue(FileSystem.stat("/") != null);
100+
}
101+
97102
function testWindowsSpecialCases() {
98103
if (Sys.systemName() != "Windows" #if python || true #end) {
99104
Assert.isTrue(true);

0 commit comments

Comments
 (0)