Add new functions to script and properly handle indexer save in the SystemWipe script

This commit is contained in:
Jeff
2024-03-13 20:58:15 +01:00
parent c117f53b5c
commit efe0843706
4 changed files with 102 additions and 1 deletions

View File

@@ -399,6 +399,16 @@ ClassFunction(stdFileRead){
return copyVariableToPtr(v);
}
ClassFunction(stdFileReadSize) {
u32 fSize = 0;
u8* buff = sd_file_read(args[0]->string.value, &fSize);
if (buff == NULL) {
SCRIPT_FATAL_ERR("Failed to read file");
}
return newIntVariablePtr(fSize);
}
ClassFunction(stdFileWrite){
return newIntVariablePtr(sd_save_to_file(args[1]->solvedArray.vector.data, args[1]->solvedArray.vector.count, args[0]->string.value));
}
@@ -506,6 +516,7 @@ STUBBED(stdFileMove)
STUBBED(stdLaunchPayload)
STUBBED(stdFileWrite)
STUBBED(stdFileRead)
STUBBED(stdFileReadSize)
STUBBED(stdCombinePaths)
STUBBED(stdEmmcFileWrite)
STUBBED(stdEmmcFileRead)
@@ -579,6 +590,7 @@ ClassFunctionTableEntry_t standardFunctionDefenitions[] = {
{"movefile", stdFileMove, 2, twoStringArgStd},
{"delfile", stdFileDel, 1, twoStringArgStd},
{"readfile", stdFileRead, 1, twoStringArgStd},
{"getfilesize", stdFileReadSize, 1, twoStringArgStd},
{"writefile", stdFileWrite, 2, oneStringOneByteArrayStd},
// Utils