More cleanup

This commit is contained in:
Scott Lahteine 2020-11-01 01:14:42 -06:00
parent 50e21a2aa2
commit 0fe8b56ede
2 changed files with 19 additions and 30 deletions

View file

@ -121,6 +121,8 @@
#define STR_NO_MEDIA "No media" #define STR_NO_MEDIA "No media"
#define STR_BEGIN_FILE_LIST "Begin file list" #define STR_BEGIN_FILE_LIST "Begin file list"
#define STR_END_FILE_LIST "End file list" #define STR_END_FILE_LIST "End file list"
#define STR_BEGIN_DIR_LIST "Begin dir list"
#define STR_END_DIR_LIST "End dir list"
#define STR_INVALID_EXTRUDER "Invalid extruder" #define STR_INVALID_EXTRUDER "Invalid extruder"
#define STR_INVALID_E_STEPPER "Invalid E stepper" #define STR_INVALID_E_STEPPER "Invalid E stepper"
#define STR_E_STEPPER_NOT_SPECIFIED "E stepper not specified" #define STR_E_STEPPER_NOT_SPECIFIED "E stepper not specified"

View file

@ -236,25 +236,23 @@ void CardReader::selectByName(SdFile dir, const char * const match, const bool d
#if ENABLED(DEBUG_CARDREADER) #if ENABLED(DEBUG_CARDREADER)
//debug = true; //debug = true;
if (debug) { if (debug) {
DEBUG_ECHOLNPGM(" "); DEBUG_ECHOLNPAIR("\n"
DEBUG_ECHOPGM(" DEBUG -SelectByName- LONG FileName: "); " DEBUG -SelectByName- LONG FileName: ", longFilename,
DEBUG_ECHO(longFilename); "-- Created FileName: ", filename,
DEBUG_ECHOPGM("-- Created FileName: "); " -- Search Term: ", match,
DEBUG_ECHO(filename); " -- Match Success: TRUE"
DEBUG_ECHOPGM(" -- Search Term: "); );
DEBUG_ECHO(match);
DEBUG_ECHOLNPGM(" -- Match Success: TRUE");
} }
#endif #endif
//This is a workaround if the filename IS the actual longfilename. This avoids reporting incorrect filenames such as "CURVE_~1.GCO" turning into "firmware.bin" // Workaround for a DOS8.3 name identical to long name.
if (strncasecmp(filename, longFilename, 3) != 0) { if (strncasecmp(filename, longFilename, 3) != 0) {
#if ENABLED(DEBUG_CARDREADER) //debug = true;
//debug = true; if (TERN0(DEBUG_CARDREADER, debug)) {
if (debug) DEBUG_ECHOLNPAIR("DEBUG: MisMatch Found! Returning LongFileName as FileName"); DEBUG_ECHOLNPAIR("DEBUG: Mismatch! Copying filename to longFilename");
if (debug) DEBUG_ECHOLNPAIR("DEBUG: filename = ", filename); DEBUG_ECHOLNPAIR("DEBUG: filename = ", filename);
if (debug) DEBUG_ECHOLNPAIR("DEBUG: longFilename = ", longFilename); DEBUG_ECHOLNPAIR("DEBUG: longFilename = ", longFilename);
#endif }
strcpy(longFilename, filename); strcpy(longFilename, filename);
} }
return; return;
@ -262,8 +260,7 @@ void CardReader::selectByName(SdFile dir, const char * const match, const bool d
else { else {
// Match Not Found -> Wipe out the filenames to avoid returning a path to a different file // Match Not Found -> Wipe out the filenames to avoid returning a path to a different file
//if (debug) DEBUG_ECHOLNPGM("FALSE"); //if (debug) DEBUG_ECHOLNPGM("FALSE");
strcpy(filename, ""); filename[0] = longFilename[0] = '\0';
strcpy(longFilename, "");
} }
#else #else
if (strcasecmp(match, filename) == 0) { if (strcasecmp(match, filename) == 0) {
@ -474,29 +471,19 @@ void CardReader::printListing(SdFile parent, const bool print_dos_names, const b
void CardReader::ls(const bool print_dos_names, const bool print_long_names) { void CardReader::ls(const bool print_dos_names, const bool print_long_names) {
if (flag.mounted) { if (flag.mounted) {
#if ENABLED(M20_REPORT_DIRECTORY_NAMES) #if ENABLED(M20_REPORT_DIRECTORY_NAMES)
SERIAL_ECHOLNPGM("Begin Directory Listing");
root.rewind(); root.rewind();
SERIAL_ECHOLNPGM(STR_BEGIN_DIR_LIST);
card.printDirListing(root, print_dos_names, print_long_names); card.printDirListing(root, print_dos_names, print_long_names);
SERIAL_ECHOLNPGM("End Directory Listing"); SERIAL_ECHOLNPGM(STR_END_DIR_LIST);
SERIAL_ECHOLNPGM(" "); SERIAL_ECHOLNPGM(" ");
#endif #endif
SERIAL_ECHOLNPGM(STR_BEGIN_FILE_LIST);
root.rewind(); root.rewind();
SERIAL_ECHOLNPGM(STR_BEGIN_FILE_LIST);
printListing(root, print_dos_names, print_long_names); printListing(root, print_dos_names, print_long_names);
SERIAL_ECHOLNPGM(STR_END_FILE_LIST); SERIAL_ECHOLNPGM(STR_END_FILE_LIST);
} }
} }
//
// List all files on the SD card
//
void CardReader::ls() {
if (flag.mounted) {
root.rewind();
printListing(root);
}
}
// //
// Echo the DOS 8.3 filename (and long filename, if any) // Echo the DOS 8.3 filename (and long filename, if any)
// //