Browse Source

move filesystem support into hxd.fs (instead of hxd.res)

ncannasse 10 years ago
parent
commit
b6094b7bac

+ 1 - 1
h3d/prim/HMDModel.hx

@@ -6,7 +6,7 @@ class HMDModel extends MeshPrimitive {
 	var dataPosition : Int;
 	var indexCount : Int;
 	var indexesTriPos : Array<Int>;
-	var entry : hxd.res.FileEntry;
+	var entry : hxd.fs.FileEntry;
 	var curMaterial : Int;
 
 	public function new(data, dataPos, entry) {

+ 2 - 2
hxd/Res.hx

@@ -12,13 +12,13 @@ class Res {
 	#end
 
 	public static macro function initEmbed(?options:haxe.macro.Expr.ExprOf<hxd.res.EmbedOptions>) {
-		return macro hxd.Res.loader = new hxd.res.Loader(hxd.res.EmbedFileSystem.create(null,$options));
+		return macro hxd.Res.loader = new hxd.res.Loader(hxd.fs.EmbedFileSystem.create(null,$options));
 	}
 
 	public static macro function initLocal() {
 		var dir = haxe.macro.Context.definedValue("resourcesPath");
 		if( dir == null ) dir = "res";
-		return macro hxd.Res.loader = new hxd.res.Loader(new hxd.res.LocalFileSystem($v{dir}));
+		return macro hxd.Res.loader = new hxd.res.Loader(new hxd.fs.LocalFileSystem($v{dir}));
 	}
 
 	public static macro function initPak() {

+ 1 - 1
hxd/fmt/hmd/Library.hx

@@ -24,7 +24,7 @@ class GeometryBuffer {
 class Library {
 
 	public var header : Data;
-	var entry : hxd.res.FileEntry;
+	var entry : hxd.fs.FileEntry;
 	var cachedPrimitives : Array<h3d.prim.Primitive>;
 	var cachedAnimations : Map<String, h3d.anim.Animation>;
 	var cachedSkin : Map<String, h3d.anim.Skin>;

+ 1 - 1
hxd/res/BytesFileSystem.hx → hxd/fs/BytesFileSystem.hx

@@ -1,4 +1,4 @@
-package hxd.res;
+package hxd.fs;
 
 class BytesFileEntry extends FileEntry {
 

+ 6 - 6
hxd/res/EmbedFileSystem.hx → hxd/fs/EmbedFileSystem.hx

@@ -1,9 +1,9 @@
-package hxd.res;
+package hxd.fs;
 
 #if !macro
 
-@:allow(hxd.res.EmbedFileSystem)
-@:access(hxd.res.EmbedFileSystem)
+@:allow(hxd.fs.EmbedFileSystem)
+@:access(hxd.fs.EmbedFileSystem)
 private class EmbedEntry extends FileEntry {
 
 	var fs : EmbedFileSystem;
@@ -258,15 +258,15 @@ class EmbedFileSystem #if !macro implements FileSystem #end {
 
 	#end
 
-	public static macro function create( ?basePath : String, ?options : EmbedOptions ) {
-		var f = new FileTree(basePath);
+	public static macro function create( ?basePath : String, ?options : hxd.res.EmbedOptions ) {
+		var f = new hxd.res.FileTree(basePath);
 		var data = f.embed(options);
 		var sdata = haxe.Serializer.run(data.tree);
 		var types = {
 			expr : haxe.macro.Expr.ExprDef.EBlock([for( t in data.types ) haxe.macro.MacroStringTools.toFieldExpr(t.split("."))]),
 			pos : haxe.macro.Context.currentPos(),
 		};
-		return macro { $types; @:privateAccess new hxd.res.EmbedFileSystem(haxe.Unserializer.run($v { sdata } )); };
+		return macro { $types; @:privateAccess new hxd.fs.EmbedFileSystem(haxe.Unserializer.run($v { sdata } )); };
 	}
 
 }

+ 1 - 1
hxd/res/FileEntry.hx → hxd/fs/FileEntry.hx

@@ -1,4 +1,4 @@
-package hxd.res;
+package hxd.fs;
 
 class FileEntry {
 

+ 1 - 1
hxd/res/FileInput.hx → hxd/fs/FileInput.hx

@@ -1,4 +1,4 @@
-package hxd.res;
+package hxd.fs;
 
 class FileInput extends haxe.io.Input {
 

+ 1 - 1
hxd/res/FileSystem.hx → hxd/fs/FileSystem.hx

@@ -1,4 +1,4 @@
-package hxd.res;
+package hxd.fs;
 
 interface FileSystem {
 	public function getRoot() : FileEntry;

+ 1 - 1
hxd/res/LoadedBitmap.hx → hxd/fs/LoadedBitmap.hx

@@ -1,4 +1,4 @@
-package hxd.res;
+package hxd.fs;
 
 typedef LoadedBitmapData = #if flash flash.display.BitmapData #elseif js js.html.Image #else Dynamic #end
 

+ 5 - 5
hxd/res/LocalFileSystem.hx → hxd/fs/LocalFileSystem.hx

@@ -1,9 +1,9 @@
-package hxd.res;
+package hxd.fs;
 
 #if (air3 || sys)
 
-@:allow(hxd.res.LocalFileSystem)
-@:access(hxd.res.LocalFileSystem)
+@:allow(hxd.fs.LocalFileSystem)
+@:access(hxd.fs.LocalFileSystem)
 private class LocalEntry extends FileEntry {
 
 	var fs : LocalFileSystem;
@@ -230,7 +230,7 @@ private class LocalEntry extends FileEntry {
 		#end
 	}
 
-	override function loadBitmap( onLoaded : hxd.res.LoadedBitmap -> Void ) : Void {
+	override function loadBitmap( onLoaded : hxd.fs.LoadedBitmap -> Void ) : Void {
 		#if flash
 		var loader = new flash.display.Loader();
 		loader.contentLoaderInfo.addEventListener(flash.events.IOErrorEvent.IO_ERROR, function(e:flash.events.IOErrorEvent) {
@@ -238,7 +238,7 @@ private class LocalEntry extends FileEntry {
 		});
 		loader.contentLoaderInfo.addEventListener(flash.events.Event.COMPLETE, function(_) {
 			var content : flash.display.Bitmap = cast loader.content;
-			onLoaded(new hxd.res.LoadedBitmap(content.bitmapData));
+			onLoaded(new hxd.fs.LoadedBitmap(content.bitmapData));
 			loader.unload();
 		});
 		loader.load(new flash.net.URLRequest(file.url));

+ 1 - 1
hxd/res/NotFound.hx → hxd/fs/NotFound.hx

@@ -1,4 +1,4 @@
-package hxd.res;
+package hxd.fs;
 
 class NotFound {
 	public var path : String;

+ 1 - 1
hxd/res/Any.hx

@@ -1,6 +1,6 @@
 package hxd.res;
 
-private class SingleFileSystem extends BytesFileSystem {
+private class SingleFileSystem extends hxd.fs.BytesFileSystem {
 
 	var path : String;
 	var bytes : haxe.io.Bytes;

+ 1 - 1
hxd/res/FbxModel.hx

@@ -28,7 +28,7 @@ class FbxModel extends Resource {
 	}
 
 	public function toHmd() : hxd.fmt.hmd.Library {
-		var hmd = new hxd.fmt.hmd.Reader(new FileInput(entry)).readHeader();
+		var hmd = new hxd.fmt.hmd.Reader(new hxd.fs.FileInput(entry)).readHeader();
 		return new hxd.fmt.hmd.Library(entry, hmd);
 	}
 

+ 1 - 1
hxd/res/Image.hx

@@ -19,7 +19,7 @@ class Image extends Resource {
 	public function getSize() : { width : Int, height : Int } {
 		if( inf != null )
 			return inf;
-		var f = new FileInput(entry);
+		var f = new hxd.fs.FileInput(entry);
 		var width = 0, height = 0, isPNG = false;
 		switch( f.readUInt16() ) {
 		case 0xD8FF: // JPG

+ 1 - 1
hxd/res/Loader.hx

@@ -2,7 +2,7 @@ package hxd.res;
 
 class Loader {
 
-	public var fs(default,null) : FileSystem;
+	public var fs(default,null) : hxd.fs.FileSystem;
 	var cache : Map<String,Dynamic>;
 
 	public function new(fs) {

+ 1 - 1
hxd/res/Resource.hx

@@ -5,7 +5,7 @@ class Resource {
 	public static var LIVE_UPDATE = #if debug true #else false #end;
 
 	public var name(get, never) : String;
-	public var entry(default,null) : FileEntry;
+	public var entry(default,null) : hxd.fs.FileEntry;
 
 	public function new(entry) {
 		this.entry = entry;