|
@@ -31,7 +31,7 @@ private enum FileKind {
|
|
|
class FileSystem {
|
|
|
|
|
|
public static function exists( path : String ) : Bool {
|
|
|
- return sys_exists(haxe.io.Path.removeTrailingSlashes(path));
|
|
|
+ return sys_exists(makeCompatiblePath(path));
|
|
|
}
|
|
|
|
|
|
public static function rename( path : String, newPath : String ) : Void {
|
|
@@ -40,7 +40,7 @@ class FileSystem {
|
|
|
}
|
|
|
|
|
|
public static function stat( path : String ) : FileStat {
|
|
|
- var s : FileStat = sys_stat(path);
|
|
|
+ var s : FileStat = sys_stat(makeCompatiblePath(path));
|
|
|
if (s==null)
|
|
|
return { gid:0, uid:0, atime:Date.fromTime(0), mtime:Date.fromTime(0), ctime:Date.fromTime(0), dev:0, ino:0, nlink:0, rdev:0, size:0, mode:0 };
|
|
|
s.atime = Date.fromTime(1000.0*(untyped s.atime));
|
|
@@ -59,7 +59,7 @@ class FileSystem {
|
|
|
}
|
|
|
|
|
|
static function kind( path : String ) : FileKind {
|
|
|
- var k:String = sys_file_type(haxe.io.Path.removeTrailingSlashes(path));
|
|
|
+ var k:String = sys_file_type(makeCompatiblePath(path));
|
|
|
return switch(k) {
|
|
|
case "file": kfile;
|
|
|
case "dir": kdir;
|
|
@@ -68,7 +68,11 @@ class FileSystem {
|
|
|
}
|
|
|
|
|
|
public static function isDirectory( path : String ) : Bool {
|
|
|
- return kind(path) == kdir;
|
|
|
+ return try {
|
|
|
+ kind(path) == kdir;
|
|
|
+ } catch(e:Dynamic) {
|
|
|
+ false;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
public static function createDirectory( path : String ) : Void {
|
|
@@ -99,6 +103,14 @@ class FileSystem {
|
|
|
return sys_read_dir(path);
|
|
|
}
|
|
|
|
|
|
+ private static inline function makeCompatiblePath(path:String):String {
|
|
|
+ return if (path.charCodeAt(1) == ":".code) {
|
|
|
+ haxe.io.Path.addTrailingSlash(path);
|
|
|
+ } else {
|
|
|
+ haxe.io.Path.removeTrailingSlashes(path);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
private static var sys_exists = cpp.Lib.load("std","sys_exists",1);
|
|
|
private static var file_delete = cpp.Lib.load("std","file_delete",1);
|
|
|
private static var sys_rename = cpp.Lib.load("std","sys_rename",2);
|