Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions Marlin/src/sd/cardreader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
);
}

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down
12 changes: 8 additions & 4 deletions Marlin/src/sd/cardreader.h
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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)
Expand Down Expand Up @@ -300,8 +304,8 @@ class CardReader {
#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; }
Expand Down Expand Up @@ -412,7 +416,7 @@ class CardReader {
//
// 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);
Expand Down
Loading