From 1d3961e77175774ea3c952fd889e7b881939a203 Mon Sep 17 00:00:00 2001 From: Mitch Bradley Date: Tue, 6 Oct 2020 09:55:17 -1000 Subject: [PATCH] Infer / at beginning of SD path name The LocalFS path processing code already inserts a / at the beginning of the path is one isn't present. This patch does the same for SD files. --- Grbl_Esp32/src/WebUI/WebSettings.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Grbl_Esp32/src/WebUI/WebSettings.cpp b/Grbl_Esp32/src/WebUI/WebSettings.cpp index 8fe4a0b7..d08a5715 100644 --- a/Grbl_Esp32/src/WebUI/WebSettings.cpp +++ b/Grbl_Esp32/src/WebUI/WebSettings.cpp @@ -666,11 +666,14 @@ namespace WebUI { #ifdef ENABLE_SD_CARD static Error openSDFile(char* parameter) { - parameter = trim(parameter); if (*parameter == '\0') { webPrintln("Missing file name!"); return Error::InvalidValue; } + String path = trim(parameter); + if (path[0] != '/') { + path = "/" + path; + } int8_t state = get_sd_state(true); if (state != SDCARD_IDLE) { if (state == SDCARD_NOT_PRESENT) { @@ -685,7 +688,7 @@ namespace WebUI { webPrintln("Busy"); return Error::IdleError; } - if (!openFile(SD, parameter)) { + if (!openFile(SD, path.c_str())) { report_status_message(Error::SdFailedRead, (espresponse) ? espresponse->client() : CLIENT_ALL); webPrintln(""); return Error::SdFailedOpenFile;