From 3a00702b676375879b4c539365dbd58458ef21c2 Mon Sep 17 00:00:00 2001 From: "andrey.zhirnov" Date: Fri, 2 Aug 2019 17:59:14 +0300 Subject: [PATCH] _spUtil_readFile now uses library module instead of vfs --- .../high/assets/spine_model_asset.cpp | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/sources/enduro2d/high/assets/spine_model_asset.cpp b/sources/enduro2d/high/assets/spine_model_asset.cpp index a84628ee..cbcf8fee 100644 --- a/sources/enduro2d/high/assets/spine_model_asset.cpp +++ b/sources/enduro2d/high/assets/spine_model_asset.cpp @@ -9,7 +9,6 @@ #include #include -#include #include #include @@ -172,7 +171,7 @@ namespace } } -void _spAtlasPage_createTexture (spAtlasPage* self, const char* path) { +extern "C" void _spAtlasPage_createTexture (spAtlasPage* self, const char* path) { try { texture_asset::load_result texture = the().load_asset(path); if ( !texture ) { @@ -186,25 +185,26 @@ void _spAtlasPage_createTexture (spAtlasPage* self, const char* path) { } } -void _spAtlasPage_disposeTexture (spAtlasPage* self) { - // acquire by smart pointer and release - texture_asset::ptr(static_cast(self->rendererObject), false); +extern "C" void _spAtlasPage_disposeTexture (spAtlasPage* self) { + // decrease ref counter + E2D_UNUSED(texture_asset::ptr(static_cast(self->rendererObject), false)); } -char* _spUtil_readFile (const char* path, int* length) { +extern "C" char* _spUtil_readFile (const char* path, int* length) { try { - input_stream_uptr stream = the().read(url(path)); - if ( !stream ) { + binary_asset::load_result file = the().load_asset(path); + if ( !file ) { throw; } - size_t size = stream->length(); - char* data = MALLOC(char, size); - size_t readn = 0; - - for ( ; readn < size; ) { - readn += stream->read(data + readn, size - readn); + if ( file->content().size() > std::numeric_limits::max() ) { + throw; } - *length = math::numeric_cast(readn); + *length = math::numeric_cast(file->content().size()); + char* data = MALLOC(char, *length); + if ( !data ) { + throw; + } + memcpy(data, file->content().data(), *length); return data; } catch(...) { the().error("SPINE: Failed to read file");