mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-02-24 10:41:24 +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) {
|
char *GodotSpineExtension::_readFile(const spine::String &path, int *length) {
|
||||||
Error error;
|
Error error;
|
||||||
auto res = FileAccess::get_file_as_array(String(path.buffer()), &error);
|
auto res = FileAccess::get_file_as_array(String(path.buffer()), &error);
|
||||||
|
|
||||||
if (error != OK) {
|
if (error != OK) {
|
||||||
if (length) *length = 0;
|
if (length) *length = 0;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (length) *length = res.size();
|
|
||||||
auto r = alloc<char>(res.size(), __FILE__, __LINE__);
|
auto r = alloc<char>(res.size(), __FILE__, __LINE__);
|
||||||
for (size_t i = 0; i < res.size(); ++i)
|
memcpy(r, res.ptr(), res.size());
|
||||||
r[i] = res[i];
|
if (length) *length = res.size();
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user