🐛 Provide 'M20 F' (list binary files) as needed (#27977)

Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>
This commit is contained in:
Hannes
2025-08-14 09:23:01 +02:00
committed by GitHub
parent a020a09903
commit f81ca65a16
2 changed files with 15 additions and 11 deletions

View File

@@ -209,11 +209,11 @@ inline bool extIsBIN(char *ext) {
//
// Return 'true' if the item is a folder, G-code file or Binary file
//
bool CardReader::is_visible_entity(const dir_t &p OPTARG(CUSTOM_FIRMWARE_UPLOAD, const bool onlyBin/*=false*/)) {
bool CardReader::is_visible_entity(const dir_t &p OPTARG(CUSTOM_FIRMWARE_UPLOAD, const bool binFiles/*=false*/)) {
//uint8_t pn0 = p.name[0];
#if DISABLED(CUSTOM_FIRMWARE_UPLOAD)
constexpr bool onlyBin = false;
constexpr bool binFiles = false;
#endif
if ( (p.attributes & DIR_ATT_HIDDEN) // Hidden by attribute
@@ -228,9 +228,9 @@ bool CardReader::is_visible_entity(const dir_t &p OPTARG(CUSTOM_FIRMWARE_UPLOAD,
return (
flag.filenameIsDir // All Directories are ok
|| fileIsBinary() // BIN files are accepted
|| (!onlyBin && p.name[8] == 'G'
&& p.name[9] != '~') // Non-backup *.G* files are accepted
|| ( binFiles && fileIsBinary()) // BIN files are accepted
|| (!binFiles && p.name[8] == 'G'
&& p.name[9] != '~') // Non-backup *.G* files are accepted
);
}
@@ -292,7 +292,7 @@ void CardReader::printListing(MediaFile parent, const char * const prepend, cons
const bool includeLong = TEST(lsflags, LS_LONG_FILENAME);
#endif
#if ENABLED(CUSTOM_FIRMWARE_UPLOAD)
const bool onlyBin = TEST(lsflags, LS_ONLY_BIN);
const bool binFiles = TEST(lsflags, LS_ONLY_BIN);
#endif
UNUSED(lsflags);
dir_t p;
@@ -328,7 +328,7 @@ void CardReader::printListing(MediaFile parent, const char * const prepend, cons
return;
}
}
else if (is_visible_entity(p OPTARG(CUSTOM_FIRMWARE_UPLOAD, onlyBin))) {
else if (is_visible_entity(p OPTARG(CUSTOM_FIRMWARE_UPLOAD, binFiles))) {
if (prepend) SERIAL_ECHO(prepend, C('/'));
SERIAL_ECHO(createFilename(filename, p), C(' '), p.fileSize);
if (includeTime) {

View File

@@ -60,6 +60,10 @@ extern const char M23_STR[], M24_STR[];
#include "Sd2Card.h"
#endif
#if ANY(DO_LIST_BIN_FILES, CUSTOM_FIRMWARE_UPLOAD)
#define MEDIA_SUPPORT_BIN_FILES 1
#endif
typedef struct {
bool saving:1, // Receiving a G-code file or logging commands during a print
logging:1, // Log enqueued commands to the open file. See GCodeQueue::advance()
@@ -69,7 +73,7 @@ typedef struct {
filenameIsDir:1, // The working item is a directory
workDirIsRoot:1, // The working directory is / so there's no parent
abort_sd_printing:1 // Abort by calling abortSDPrinting() at the main loop()
#if DO_LIST_BIN_FILES
#if MEDIA_SUPPORT_BIN_FILES
, filenameIsBin:1 // The working item is a BIN file
#endif
#if ENABLED(BINARY_FILE_TRANSFER)
@@ -300,8 +304,8 @@ public:
#endif
// Binary flag for the current file
static bool fileIsBinary() { return TERN0(DO_LIST_BIN_FILES, flag.filenameIsBin); }
static void setBinFlag(const bool bin) { TERN(DO_LIST_BIN_FILES, flag.filenameIsBin = bin, UNUSED(bin)); }
static bool fileIsBinary() { return TERN0(MEDIA_SUPPORT_BIN_FILES, flag.filenameIsBin); }
static void setBinFlag(const bool bin) { TERN(MEDIA_SUPPORT_BIN_FILES, flag.filenameIsBin = bin, UNUSED(bin)); }
// Current Working Dir - Set by cd, cdup, cdroot, and diveToFile(true, ...)
static char* getWorkDirName() { workDir.getDosName(filename); return filename; }
@@ -412,7 +416,7 @@ private:
//
// Directory items
//
static bool is_visible_entity(const dir_t &p OPTARG(CUSTOM_FIRMWARE_UPLOAD, const bool onlyBin=false));
static bool is_visible_entity(const dir_t &p OPTARG(CUSTOM_FIRMWARE_UPLOAD, const bool binFiles=false));
static int16_t countVisibleItems(MediaFile dir);
static void selectByIndex(MediaFile dir, const int16_t index);
static void selectByName(MediaFile dir, const char * const match);