gcode: M30 - Properly handle absolute paths and relative paths#5190
gcode: M30 - Properly handle absolute paths and relative paths#5190bkerler wants to merge 1 commit intoprusa3d:masterfrom
Conversation
| */ | ||
| void GcodeSuite::M30() { | ||
| // Skip leading whitespace | ||
| const char *filename = parser.string_arg; |
|
|
||
| // Handle Simplify3D format which includes file size after a space (same as M23) | ||
| for (char *fn = const_cast<char *>(filename); *fn; ++fn) { | ||
| if (*fn == ' ') { |
There was a problem hiding this comment.
Does the firmware handle escape characters? That is, if I type in hello\ world.gcode, will it recognize it the entire filename? Does the firmware allow the user to upload files with spaces in their names?
There was a problem hiding this comment.
The gcode parser has no escape character mechanism. The truncation-at-space is intentional — it mirrors what M23 does for Simplify3D compatibility (where the host appends a file size, e.g. M30 filename.gcode 12345).
| } | ||
|
|
||
| // Skip empty filename | ||
| if (!filename || !*filename) { |
There was a problem hiding this comment.
if we need to check for nullptr, then yes
|
|
||
| // Handle paths that may already have /usb/ or /sd/ prefix | ||
| if (strncmp(filename, "/usb/", 5) == 0 || strncmp(filename, "/sd/", 4) == 0) { | ||
| filepath.append_string(filename); |
There was a problem hiding this comment.
You need to test whether the filename is too long to fit into filepath.
There was a problem hiding this comment.
ArrayStringBuilder already tracks overflows, but yeah, will check the is_ok function.
This fixes issue #5005.
The M30 command (delete file on SD/USB) was failing because it didn't properly handle: