Merge pull request #2108 from thinkyhead/m33_long_filename_host_support
M33 LONG_FILENAME_HOST_SUPPORT
This commit is contained in:
@ -129,6 +129,69 @@ void CardReader::ls() {
|
||||
lsDive("", root);
|
||||
}
|
||||
|
||||
#ifdef LONG_FILENAME_HOST_SUPPORT
|
||||
|
||||
/**
|
||||
* Get a long pretty path based on a DOS 8.3 path
|
||||
*/
|
||||
void CardReader::printLongPath(char *path) {
|
||||
lsAction = LS_GetFilename;
|
||||
|
||||
int i, pathLen = strlen(path);
|
||||
|
||||
// SERIAL_ECHOPGM("Full Path: "); SERIAL_ECHOLN(path);
|
||||
|
||||
// Zero out slashes to make segments
|
||||
for (i = 0; i < pathLen; i++) if (path[i] == '/') path[i] = '\0';
|
||||
|
||||
SdFile diveDir = root; // start from the root for segment 1
|
||||
for (i = 0; i < pathLen;) {
|
||||
|
||||
if (path[i] == '\0') i++; // move past a single nul
|
||||
|
||||
char *segment = &path[i]; // The segment after most slashes
|
||||
|
||||
// If a segment is empty (extra-slash) then exit
|
||||
if (!*segment) break;
|
||||
|
||||
// Go to the next segment
|
||||
while (path[++i]) { }
|
||||
|
||||
// SERIAL_ECHOPGM("Looking for segment: "); SERIAL_ECHOLN(segment);
|
||||
|
||||
// Find the item, setting the long filename
|
||||
diveDir.rewind();
|
||||
lsDive("", diveDir, segment);
|
||||
|
||||
// Print /LongNamePart to serial output
|
||||
SERIAL_PROTOCOLCHAR('/');
|
||||
SERIAL_PROTOCOL(longFilename[0] ? longFilename : "???");
|
||||
|
||||
// If the filename was printed then that's it
|
||||
if (!filenameIsDir) break;
|
||||
|
||||
// SERIAL_ECHOPGM("Opening dir: "); SERIAL_ECHOLN(segment);
|
||||
|
||||
// Open the sub-item as the new dive parent
|
||||
SdFile dir;
|
||||
if (!dir.open(diveDir, segment, O_READ)) {
|
||||
SERIAL_EOL;
|
||||
SERIAL_ECHO_START;
|
||||
SERIAL_ECHOPGM(MSG_SD_CANT_OPEN_SUBDIR);
|
||||
SERIAL_ECHO(segment);
|
||||
break;
|
||||
}
|
||||
|
||||
diveDir.close();
|
||||
diveDir = dir;
|
||||
|
||||
} // while i<pathLen
|
||||
|
||||
SERIAL_EOL;
|
||||
}
|
||||
|
||||
#endif // LONG_FILENAME_HOST_SUPPORT
|
||||
|
||||
void CardReader::initsd() {
|
||||
cardOK = false;
|
||||
if (root.isOpen()) root.close();
|
||||
@ -429,7 +492,7 @@ void CardReader::checkautostart(bool force) {
|
||||
if (!cardOK) return; // fail
|
||||
}
|
||||
|
||||
char autoname[30];
|
||||
char autoname[10];
|
||||
sprintf_P(autoname, PSTR("auto%i.g"), autostart_index);
|
||||
for (int8_t i = 0; i < (int8_t)strlen(autoname); i++) autoname[i] = tolower(autoname[i]);
|
||||
|
||||
@ -441,7 +504,7 @@ void CardReader::checkautostart(bool force) {
|
||||
while (root.readDir(p, NULL) > 0) {
|
||||
for (int8_t i = 0; i < (int8_t)strlen((char*)p.name); i++) p.name[i] = tolower(p.name[i]);
|
||||
if (p.name[9] != '~' && strncmp((char*)p.name, autoname, 5) == 0) {
|
||||
char cmd[30];
|
||||
char cmd[4 + (FILENAME_LENGTH + 1) * MAX_DIR_DEPTH + 2];
|
||||
sprintf_P(cmd, PSTR("M23 %s"), autoname);
|
||||
enqueuecommand(cmd);
|
||||
enqueuecommands_P(PSTR("M24"));
|
||||
|
Reference in New Issue
Block a user