Skip to content

Commit

Permalink
Case-independent GCode file extensions
Browse files Browse the repository at this point in the history
  • Loading branch information
MitchBradley committed Dec 23, 2024
1 parent 4eec327 commit ae0055d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion FluidNC/src/Channel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "Logging.h"
#include "Job.h"
#include <string_view>
#include <algorithm>

void Channel::flushRx() {
_linelen = 0;
Expand Down Expand Up @@ -328,7 +329,7 @@ void Channel::sendLine(MsgLevel level, const std::string& line) {
}
}

bool Channel::is_visible(const std::string& stem, const std::string& extension, bool isdir) {
bool Channel::is_visible(const std::string& stem, std::string extension, bool isdir) {
if (stem.length() && stem[0] == '.') {
// Exclude hidden files and directories
return false;
Expand All @@ -341,6 +342,9 @@ bool Channel::is_visible(const std::string& stem, const std::string& extension,
return true;
}

// Convert extension to canonical lower case format
std::transform(extension.begin(), extension.end(), extension.begin(), [](unsigned char c) { return std::tolower(c); });

// common gcode extensions
std::string_view extensions(".g .gc .gco .gcode .nc .ngc .ncc .txt .cnc .tap");
int pos = 0;
Expand Down
2 changes: 1 addition & 1 deletion FluidNC/src/Channel.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ class Channel : public Stream {
return readBytes(buffer, length);
}

virtual bool is_visible(const std::string& stem, const std::string& extension, bool isdir);
virtual bool is_visible(const std::string& stem, std::string extension, bool isdir);

size_t timedReadBytes(uint8_t* buffer, size_t length, TickType_t timeout) {
return timedReadBytes(reinterpret_cast<char*>(buffer), length, timeout);
Expand Down

0 comments on commit ae0055d

Please sign in to comment.