1
0
Fork 0
mirror of https://github.com/suchmememanyskill/TegraExplorer.git synced 2024-11-22 20:06:43 +00:00
TegraExplorer/source/script/saveClass.c
suchmememanyskill 2ddc7ae2a9 tsv3 start ig
2021-07-09 22:56:13 +02:00

30 lines
No EOL
873 B
C

#include "saveClass.h"
#include "compat.h"
u8 oneStringArgSave[] = {StringClass};
ClassFunction(readFile){
Variable_t *arg = (*args);
save_data_file_ctx_t dataArc;
if (!save_open_file(&caller->save->saveCtx, &dataArc, arg->string.value, OPEN_MODE_READ))
return NULL;
u64 totalSize;
save_data_file_get_size(&dataArc, &totalSize);
u8 *buff = malloc(totalSize);
save_data_file_read(&dataArc, &totalSize, 0, buff, totalSize);
Variable_t a = {.variableType = ByteArrayClass};
a.solvedArray.vector = vecFromArray(buff, totalSize, 1);
return copyVariableToPtr(a);
}
ClassFunctionTableEntry_t saveFunctions[] = {
{"readFile", readFile, 1, oneStringArgSave},
};
Variable_t getSaveMember(Variable_t* var, char* memberName) {
return getGenericFunctionMember(var, memberName, saveFunctions, ARRAY_SIZE(saveFunctions));
}