Skip to content

Commit

Permalink
Add support for delete file via M30 gcode command
Browse files Browse the repository at this point in the history
  • Loading branch information
bkerler authored and schrodlm committed Jan 30, 2025
1 parent ebe7455 commit 8eef110
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/marlin_stubs/sdcard/M20-M30_M32-M34.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
#include <dirent.h>

#include "../../lib/Marlin/Marlin/src/gcode/gcode.h"
#include "../src/common/print_utils.hpp"
#include "marlin_server.hpp"
#include "media.hpp"
#include "marlin_vars.hpp"
#include <str_utils.hpp>

/** \addtogroup G-Codes
* @{
Expand Down Expand Up @@ -124,7 +126,15 @@ void GcodeSuite::M29() {

// M30 - Delete a file on the SD card
void GcodeSuite::M30() {
// TODO
ArrayStringBuilder<FF_MAX_LFN> filepath;
filepath.append_printf("/usb/%s", parser.string_arg);
DeleteResult result = DeleteResult::GeneralError;
if (filepath.is_ok()) {
result = remove_file(filepath.str());
}
SERIAL_ECHOPGM(result == DeleteResult::Success ? "File deleted:" : "Deletion failed:");
SERIAL_ECHO(parser.string_arg);
SERIAL_ECHOLN(".");
}

// M32 - Select file and start SD print
Expand Down

0 comments on commit 8eef110

Please sign in to comment.