diff --git a/lime/utils/ByteArray.hx b/lime/utils/ByteArray.hx index fd13fd40c..c64da9d1d 100644 --- a/lime/utils/ByteArray.hx +++ b/lime/utils/ByteArray.hx @@ -328,11 +328,11 @@ class ByteArray #if !js extends Bytes implements ArrayAccess implements IDa public static function readFile (path:String):ByteArray { - #if html5 - return null; - #else - return ByteArray.fromBytes (File.getBytes (path)); + #if !html5 + var data = lime_bytes_read_file (path); + if (data != null) return ByteArray.fromBytes (@:privateAccess new Bytes (data.length, data.b)); #end + return null; } @@ -1093,6 +1093,7 @@ class ByteArray #if !js extends Bytes implements ArrayAccess implements IDa private static var lime_bytes_get_data_pointer = System.load ("lime", "lime_bytes_get_data_pointer", 1); + private static var lime_bytes_read_file = System.load ("lime", "lime_bytes_read_file", 1); } diff --git a/project/src/ExternalInterface.cpp b/project/src/ExternalInterface.cpp index d1e3de508..8835cc269 100644 --- a/project/src/ExternalInterface.cpp +++ b/project/src/ExternalInterface.cpp @@ -135,6 +135,14 @@ namespace lime { } + value lime_bytes_read_file (value path) { + + Bytes data = Bytes (val_os_string (path)); + return data.Value (); + + } + + void lime_font_destroy (value handle) { Font *font = (Font*)(intptr_t)val_float (handle); @@ -1104,6 +1112,7 @@ namespace lime { DEFINE_PRIM (lime_application_update, 1); DEFINE_PRIM (lime_audio_load, 1); DEFINE_PRIM (lime_bytes_get_data_pointer, 1); + DEFINE_PRIM (lime_bytes_read_file, 1); DEFINE_PRIM (lime_font_get_ascender, 1); DEFINE_PRIM (lime_font_get_descender, 1); DEFINE_PRIM (lime_font_get_family_name, 1);