From 40c9a8747efb5459415d0d4b4e96d398daeb2a50 Mon Sep 17 00:00:00 2001 From: Nathanne Isip Date: Sun, 19 May 2024 01:55:59 +0800 Subject: [PATCH] Fixed disabling /bin/boot.bin mechanics. --- src/rishka_vm.cpp | 4 ++-- src/rishka_vm.h | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/rishka_vm.cpp b/src/rishka_vm.cpp index e341b4a..8c964dc 100644 --- a/src/rishka_vm.cpp +++ b/src/rishka_vm.cpp @@ -56,7 +56,7 @@ char* RishkaVM::getArgValue(const uint8_t index) const { return this->argv[index]; } -bool RishkaVM::loadFile(const char* fileName) { +bool RishkaVM::loadFile(const char* fileName, bool disableBoot) { String absoluteFilename = "/bin/" + String(fileName) + ".bin"; if(!SD.exists(absoluteFilename)) absoluteFilename = rishka_sanitize_path( @@ -71,7 +71,7 @@ bool RishkaVM::loadFile(const char* fileName) { if(!SD.exists(absoluteFilename)) return false; - if(absoluteFilename == "/bin/boot.bin") + if(!disableBoot && absoluteFilename == "/bin/boot.bin") return false; File file = SD.open(absoluteFilename); diff --git a/src/rishka_vm.h b/src/rishka_vm.h index 08e6e94..84b72be 100644 --- a/src/rishka_vm.h +++ b/src/rishka_vm.h @@ -216,9 +216,10 @@ class RishkaVM final { * for execution. * * @param fileName The name of the program file to be loaded. + * @param disableBoot Disable loading the /bin/boot.bin program. * @return true if the file is loaded successfully, false otherwise. */ - bool loadFile(const char* fileName); + bool loadFile(const char* fileName, bool disableBoot = true); /** * @brief Runs the Rishka virtual machine instance.