Browse Source

fixed embedfs with new hxd.res.FileTree

ncannasse 7 năm trước cách đây
mục cha
commit
9d80cffdcc
1 tập tin đã thay đổi với 12 bổ sung1 xóa
  1. 12 1
      hxd/fs/EmbedFileSystem.hx

+ 12 - 1
hxd/fs/EmbedFileSystem.hx

@@ -263,10 +263,21 @@ class EmbedFileSystem #if !macro implements FileSystem #end {
 
 
 	#end
 	#end
 
 
+	#if macro
+	static function makeTree( t : hxd.res.FileTree.FileTreeData ) : Dynamic {
+		var o = {};
+		for( d in t.dirs )
+			Reflect.setField(o, d.name, makeTree(d));
+		for( f in t.files )
+			Reflect.setField(o, f.file, true);
+		return o;
+	}
+	#end
+
 	public static macro function create( ?basePath : String, ?options : hxd.res.EmbedOptions ) {
 	public static macro function create( ?basePath : String, ?options : hxd.res.EmbedOptions ) {
 		var f = new hxd.res.FileTree(basePath);
 		var f = new hxd.res.FileTree(basePath);
 		var data = f.embed(options);
 		var data = f.embed(options);
-		var sdata = haxe.Serializer.run(data.tree);
+		var sdata = haxe.Serializer.run(makeTree(data.tree));
 		var types = {
 		var types = {
 			expr : haxe.macro.Expr.ExprDef.EBlock([for( t in data.types ) haxe.macro.MacroStringTools.toFieldExpr(t.split("."))]),
 			expr : haxe.macro.Expr.ExprDef.EBlock([for( t in data.types ) haxe.macro.MacroStringTools.toFieldExpr(t.split("."))]),
 			pos : haxe.macro.Context.currentPos(),
 			pos : haxe.macro.Context.currentPos(),