mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-02-13 10:38:46 +08:00
Better SpineExtension:readFile implementation.
This commit is contained in:
parent
91748c2bbc
commit
aa84a4244f
@ -62,15 +62,12 @@ void GodotSpineExtension::_free(void *mem, const char *file, int line) {
|
||||
char *GodotSpineExtension::_readFile(const spine::String &path, int *length) {
|
||||
Error error;
|
||||
auto res = FileAccess::get_file_as_array(String(path.buffer()), &error);
|
||||
|
||||
if (error != OK) {
|
||||
if (length) *length = 0;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (length) *length = res.size();
|
||||
auto r = alloc<char>(res.size(), __FILE__, __LINE__);
|
||||
for (size_t i = 0; i < res.size(); ++i)
|
||||
r[i] = res[i];
|
||||
memcpy(r, res.ptr(), res.size());
|
||||
if (length) *length = res.size();
|
||||
return r;
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user