From 96fcc5e1a559a305aa524a27f63591cd3e4488a7 Mon Sep 17 00:00:00 2001 From: fgiudice98 <35608074+fgiudice98@users.noreply.github.com> Date: Wed, 15 Dec 2021 16:03:01 +0100 Subject: [PATCH] M23 fix Fixes M23 not able to open a file in a folder Thanks to [this github comment](https://github.com/MarlinFirmware/Marlin/issues/19109#issuecomment-680196123) --- Marlin/Marlin_main.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index 8b22aeeaf..4546e8667 100644 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -7643,12 +7643,20 @@ inline void gcode_M17() { * M23: Open a file */ inline void gcode_M23() { + byte filenameSlash = 0; #if ENABLED(POWER_LOSS_RECOVERY) card.removeJobRecoveryFile(); #endif // Simplify3D includes the size, so zero out all spaces (#7227) - for (char *fn = parser.string_arg; *fn; ++fn) if (*fn == ' ') *fn = '\0'; - card.openFile(parser.string_arg, true); + for (char *fn = parser.string_arg; *fn; ++fn){ + if (*fn == ' ') *fn = '\0'; + if (*fn == '/') filenameSlash += 1; + } + if (filenameSlash > 1){ + card.openFile(&parser.string_arg[1], true); + } else { + card.openFile(parser.string_arg, true); + } } /**