Browse Source

added listDirectory

ncannasse 9 years ago
parent
commit
8aa8ce7fea
1 changed files with 14 additions and 0 deletions
  1. 14 0
      hxd/File.hx

+ 14 - 0
hxd/File.hx

@@ -169,6 +169,20 @@ class File {
 		#end
 		#end
 	}
 	}
 
 
+	public static function listDirectory( path : String ) {
+		#if air3
+		try {
+			return [for( f in getRelPath(path).getDirectoryListing() ) f.name];
+		} catch( e : Dynamic ) {
+			return [];
+		}
+		#elseif sys
+		return sys.FileSystem.readDirectory(path);
+		#else
+		throw "Not supported";
+		#end
+	}
+
 	public static function getBytes( path : String ) : haxe.io.Bytes {
 	public static function getBytes( path : String ) : haxe.io.Bytes {
 		#if air3
 		#if air3
 		var file = getRelPath(path);
 		var file = getRelPath(path);