Fix WorkDirDepth limit (for good this time)
This commit is contained in:
parent
90c0f33bc5
commit
84d043d41b
@ -666,7 +666,7 @@ uint16_t CardReader::getnrfilenames()
|
||||
return nrFiles;
|
||||
}
|
||||
|
||||
void CardReader::chdir(const char * relpath)
|
||||
bool CardReader::chdir(const char * relpath)
|
||||
{
|
||||
SdFile newfile;
|
||||
SdFile *parent=&root;
|
||||
@ -674,11 +674,12 @@ void CardReader::chdir(const char * relpath)
|
||||
if(workDir.isOpen())
|
||||
parent=&workDir;
|
||||
|
||||
if(!newfile.open(*parent,relpath, O_READ))
|
||||
if(!newfile.open(*parent,relpath, O_READ) || ((workDirDepth + 1) >= MAX_DIR_DEPTH))
|
||||
{
|
||||
SERIAL_ECHO_START;
|
||||
SERIAL_ECHORPGM(_n("Cannot enter subdir: "));////MSG_SD_CANT_ENTER_SUBDIR
|
||||
SERIAL_ECHOLN(relpath);
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -691,6 +692,7 @@ void CardReader::chdir(const char * relpath)
|
||||
#ifdef SDCARD_SORT_ALPHA
|
||||
presort();
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -39,7 +39,7 @@ public:
|
||||
|
||||
|
||||
void ls(bool printLFN);
|
||||
void chdir(const char * relpath);
|
||||
bool chdir(const char * relpath);
|
||||
void updir();
|
||||
void setroot();
|
||||
|
||||
|
@ -8490,13 +8490,16 @@ static void menu_action_sdfile(const char* filename)
|
||||
|
||||
void menu_action_sddirectory(const char* filename)
|
||||
{
|
||||
uint8_t depth = (uint8_t)card.getWorkDirDepth();
|
||||
bool success = card.chdir(filename);
|
||||
|
||||
strcpy(dir_names[depth], filename);
|
||||
MYSERIAL.println(dir_names[depth]);
|
||||
card.chdir(filename);
|
||||
lcd_encoder = 0;
|
||||
menu_data_reset(); //Forces reloading of cached variables.
|
||||
if (success)
|
||||
{
|
||||
strcpy(dir_names[card.getWorkDirDepth()], filename);
|
||||
MYSERIAL.println(filename);
|
||||
}
|
||||
|
||||
lcd_encoder = 0;
|
||||
menu_data_reset(); //Forces reloading of cached variables.
|
||||
}
|
||||
|
||||
/** LCD API **/
|
||||
|
Loading…
Reference in New Issue
Block a user