|
@@ -20,6 +20,10 @@
|
|
* DEALINGS IN THE SOFTWARE.
|
|
* DEALINGS IN THE SOFTWARE.
|
|
*/
|
|
*/
|
|
package haxe;
|
|
package haxe;
|
|
|
|
+#if python
|
|
|
|
+import haxe.io.Bytes;
|
|
|
|
+import haxe.io.BytesData;
|
|
|
|
+#end
|
|
|
|
|
|
/**
|
|
/**
|
|
Resource can be used to access resources that were added through the
|
|
Resource can be used to access resources that were added through the
|
|
@@ -35,7 +39,7 @@ class Resource {
|
|
#if (java || cs)
|
|
#if (java || cs)
|
|
@:keep static var content : Array<String>;
|
|
@:keep static var content : Array<String>;
|
|
#elseif python
|
|
#elseif python
|
|
- static var content : python.lib.Types.Dict<String, String>;
|
|
|
|
|
|
+ static var content : python.lib.Types.Dict<String, BytesData>;
|
|
#else
|
|
#else
|
|
static var content : Array<{ name : String, data : String, str : String }>;
|
|
static var content : Array<{ name : String, data : String, str : String }>;
|
|
#end
|
|
#end
|
|
@@ -98,6 +102,7 @@ class Resource {
|
|
return new cs.io.NativeInput(str).readAll().toString();
|
|
return new cs.io.NativeInput(str).readAll().toString();
|
|
return null;
|
|
return null;
|
|
#elseif python
|
|
#elseif python
|
|
|
|
+ #if embed_resources
|
|
for( k in content.keys().iter() )
|
|
for( k in content.keys().iter() )
|
|
if( k == name ) {
|
|
if( k == name ) {
|
|
var b : haxe.io.Bytes = haxe.crypto.Base64.decode(content.get(k, null));
|
|
var b : haxe.io.Bytes = haxe.crypto.Base64.decode(content.get(k, null));
|
|
@@ -105,6 +110,9 @@ class Resource {
|
|
|
|
|
|
}
|
|
}
|
|
return null;
|
|
return null;
|
|
|
|
+ #else
|
|
|
|
+ return content.hasKey(name) ? Bytes.ofData(content.get(name,null)).toString() : null;
|
|
|
|
+ #end
|
|
#else
|
|
#else
|
|
for( x in content )
|
|
for( x in content )
|
|
if( x.name == name ) {
|
|
if( x.name == name ) {
|
|
@@ -140,12 +148,16 @@ class Resource {
|
|
return new cs.io.NativeInput(str).readAll();
|
|
return new cs.io.NativeInput(str).readAll();
|
|
return null;
|
|
return null;
|
|
#elseif python
|
|
#elseif python
|
|
|
|
+ #if embed_resources
|
|
for( k in content.keys().iter() )
|
|
for( k in content.keys().iter() )
|
|
if( k == name ) {
|
|
if( k == name ) {
|
|
var b : haxe.io.Bytes = haxe.crypto.Base64.decode(content.get(k, null));
|
|
var b : haxe.io.Bytes = haxe.crypto.Base64.decode(content.get(k, null));
|
|
return b;
|
|
return b;
|
|
|
|
|
|
}
|
|
}
|
|
|
|
+ #else
|
|
|
|
+ return Bytes.ofData(content.get(name,null));
|
|
|
|
+ #end
|
|
return null;
|
|
return null;
|
|
#else
|
|
#else
|
|
for( x in content )
|
|
for( x in content )
|