Bläddra i källkod

Fix #6489 (#8548)

* fix #6489

* test

* consistent

* fix eval
Aurel 6 år sedan
förälder
incheckning
ff76576bf3

+ 1 - 0
src/macro/eval/evalStdLib.ml

@@ -1189,6 +1189,7 @@ module StdFileSystem = struct
 
 	let patch_path s =
 		if String.length s > 1 && String.length s <= 3 && s.[1] = ':' then Path.add_trailing_slash s
+		else if s = "/" then "/"
 		else remove_trailing_slash s
 
 	let createDirectory = vfun1 (fun path ->

+ 2 - 0
std/cpp/_std/sys/FileSystem.hx

@@ -104,6 +104,8 @@ class FileSystem {
 	private static inline function makeCompatiblePath(path:String):String {
 		return if (path.charCodeAt(1) == ":".code && path.length <= 3) {
 			haxe.io.Path.addTrailingSlash(path);
+		} else if (path == "/") {
+			"/";
 		} else {
 			haxe.io.Path.removeTrailingSlashes(path);
 		}

+ 2 - 0
std/hl/_std/sys/FileSystem.hx

@@ -102,6 +102,8 @@ class FileSystem {
 	private static inline function makeCompatiblePath(path:String):String {
 		return if (path.charCodeAt(1) == ":".code && path.length <= 3) {
 			haxe.io.Path.addTrailingSlash(path);
+		} else if (path == "/") {
+			"/";
 		} else {
 			haxe.io.Path.removeTrailingSlashes(path);
 		}

+ 2 - 0
std/neko/_std/sys/FileSystem.hx

@@ -104,6 +104,8 @@ class FileSystem {
 	private static inline function makeCompatiblePath(path:String):String {
 		return if (path.charCodeAt(1) == ":".code && path.length <= 3) {
 			haxe.io.Path.addTrailingSlash(path);
+		} else if (path == "/") {
+			"/";
 		} else {
 			haxe.io.Path.removeTrailingSlashes(path);
 		}

+ 5 - 0
tests/sys/src/TestFileSystem.hx

@@ -94,6 +94,11 @@ class TestFileSystem extends utest.Test {
 		}
 	}
 
+	function testRootExists() {
+		Assert.isTrue(FileSystem.exists("/"));
+		Assert.isTrue(FileSystem.stat("/") != null);
+	}
+
 	function testWindowsSpecialCases() {
 		if (Sys.systemName() != "Windows" #if python || true #end) {
 			Assert.isTrue(true);