1
0
mirror of https://github.com/bdring/Grbl_Esp32.git synced 2025-09-02 19:02:35 +02:00

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.
This commit is contained in:
Mitch Bradley
2020-10-06 09:55:17 -10:00
parent d5ba88d5e4
commit 1d3961e771

View File

@@ -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;