Rename lastnr to autostart_index and...
Replace instances of the number 13 with FILENAME_LENGTH where appropriate.
This commit is contained in:
parent
23fcd1ecb2
commit
1ed3913333
5 changed files with 23 additions and 21 deletions
|
@ -1012,7 +1012,7 @@ void SdBaseFile::printFatTime( uint16_t fatTime) {
|
||||||
* the value zero, false, is returned for failure.
|
* the value zero, false, is returned for failure.
|
||||||
*/
|
*/
|
||||||
bool SdBaseFile::printName() {
|
bool SdBaseFile::printName() {
|
||||||
char name[13];
|
char name[FILENAME_LENGTH];
|
||||||
if (!getFilename(name)) return false;
|
if (!getFilename(name)) return false;
|
||||||
MYSERIAL.print(name);
|
MYSERIAL.print(name);
|
||||||
return true;
|
return true;
|
||||||
|
@ -1135,7 +1135,7 @@ int8_t SdBaseFile::readDir(dir_t* dir, char* longFilename) {
|
||||||
if (VFAT->firstClusterLow == 0 && (VFAT->sequenceNumber & 0x1F) > 0 && (VFAT->sequenceNumber & 0x1F) <= MAX_VFAT_ENTRIES)
|
if (VFAT->firstClusterLow == 0 && (VFAT->sequenceNumber & 0x1F) > 0 && (VFAT->sequenceNumber & 0x1F) <= MAX_VFAT_ENTRIES)
|
||||||
{
|
{
|
||||||
//TODO: Store the filename checksum to verify if a none-long filename aware system modified the file table.
|
//TODO: Store the filename checksum to verify if a none-long filename aware system modified the file table.
|
||||||
n = ((VFAT->sequenceNumber & 0x1F) - 1) * 13;
|
n = ((VFAT->sequenceNumber & 0x1F) - 1) * FILENAME_LENGTH;
|
||||||
longFilename[n+0] = VFAT->name1[0];
|
longFilename[n+0] = VFAT->name1[0];
|
||||||
longFilename[n+1] = VFAT->name1[1];
|
longFilename[n+1] = VFAT->name1[1];
|
||||||
longFilename[n+2] = VFAT->name1[2];
|
longFilename[n+2] = VFAT->name1[2];
|
||||||
|
@ -1151,7 +1151,7 @@ int8_t SdBaseFile::readDir(dir_t* dir, char* longFilename) {
|
||||||
longFilename[n+12] = VFAT->name3[1];
|
longFilename[n+12] = VFAT->name3[1];
|
||||||
//If this VFAT entry is the last one, add a NUL terminator at the end of the string
|
//If this VFAT entry is the last one, add a NUL terminator at the end of the string
|
||||||
if (VFAT->sequenceNumber & 0x40)
|
if (VFAT->sequenceNumber & 0x40)
|
||||||
longFilename[n+13] = '\0';
|
longFilename[n+FILENAME_LENGTH] = '\0';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// return if normal file or subdirectory
|
// return if normal file or subdirectory
|
||||||
|
|
|
@ -108,15 +108,17 @@ uint8_t const SOFT_SPI_SCK_PIN = 13;
|
||||||
* a pure virtual function is called.
|
* a pure virtual function is called.
|
||||||
*/
|
*/
|
||||||
#define USE_CXA_PURE_VIRTUAL 1
|
#define USE_CXA_PURE_VIRTUAL 1
|
||||||
|
|
||||||
|
/** Number of UTF-16 characters per entry */
|
||||||
|
#define FILENAME_LENGTH 13
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Defines for long (vfat) filenames
|
* Defines for long (vfat) filenames
|
||||||
*/
|
*/
|
||||||
/** Number of VFAT entries used. Every entry has 13 UTF-16 characters */
|
/** Number of VFAT entries used. Every entry has 13 UTF-16 characters */
|
||||||
#define MAX_VFAT_ENTRIES (2)
|
#define MAX_VFAT_ENTRIES (2)
|
||||||
/** Number of UTF-16 characters per entry */
|
|
||||||
#define FILENAME_LENGTH 13
|
|
||||||
/** Total size of the buffer used to store the long filenames */
|
/** Total size of the buffer used to store the long filenames */
|
||||||
#define LONG_FILENAME_LENGTH (13*MAX_VFAT_ENTRIES+1)
|
#define LONG_FILENAME_LENGTH (FILENAME_LENGTH*MAX_VFAT_ENTRIES+1)
|
||||||
#endif // SdFatConfig_h
|
#endif // SdFatConfig_h
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@ CardReader::CardReader()
|
||||||
memset(workDirParents, 0, sizeof(workDirParents));
|
memset(workDirParents, 0, sizeof(workDirParents));
|
||||||
|
|
||||||
autostart_stilltocheck=true; //the SD start is delayed, because otherwise the serial cannot answer fast enough to make contact with the host software.
|
autostart_stilltocheck=true; //the SD start is delayed, because otherwise the serial cannot answer fast enough to make contact with the host software.
|
||||||
lastnr=0;
|
autostart_index=0;
|
||||||
//power to SD reader
|
//power to SD reader
|
||||||
#if SDPOWER > -1
|
#if SDPOWER > -1
|
||||||
SET_OUTPUT(SDPOWER);
|
SET_OUTPUT(SDPOWER);
|
||||||
|
@ -60,8 +60,8 @@ void CardReader::lsDive(const char *prepend, SdFile parent, const char * const m
|
||||||
if( DIR_IS_SUBDIR(&p) && lsAction!=LS_Count && lsAction!=LS_GetFilename) // hence LS_SerialPrint
|
if( DIR_IS_SUBDIR(&p) && lsAction!=LS_Count && lsAction!=LS_GetFilename) // hence LS_SerialPrint
|
||||||
{
|
{
|
||||||
|
|
||||||
char path[13*2];
|
char path[FILENAME_LENGTH*2];
|
||||||
char lfilename[13];
|
char lfilename[FILENAME_LENGTH];
|
||||||
createFilename(lfilename,p);
|
createFilename(lfilename,p);
|
||||||
|
|
||||||
path[0]=0;
|
path[0]=0;
|
||||||
|
@ -241,7 +241,7 @@ void CardReader::getAbsFilename(char *t)
|
||||||
while(*t!=0 && cnt< MAXPATHNAMELENGTH)
|
while(*t!=0 && cnt< MAXPATHNAMELENGTH)
|
||||||
{t++;cnt++;} //crawl counter forward.
|
{t++;cnt++;} //crawl counter forward.
|
||||||
}
|
}
|
||||||
if(cnt<MAXPATHNAMELENGTH-13)
|
if(cnt<MAXPATHNAMELENGTH-FILENAME_LENGTH)
|
||||||
file.getFilename(t);
|
file.getFilename(t);
|
||||||
else
|
else
|
||||||
t[0]=0;
|
t[0]=0;
|
||||||
|
@ -311,7 +311,7 @@ void CardReader::openFile(char* name,bool read, bool replace_current/*=true*/)
|
||||||
//SERIAL_ECHO("end :");SERIAL_ECHOLN((int)(dirname_end-name));
|
//SERIAL_ECHO("end :");SERIAL_ECHOLN((int)(dirname_end-name));
|
||||||
if(dirname_end>0 && dirname_end>dirname_start)
|
if(dirname_end>0 && dirname_end>dirname_start)
|
||||||
{
|
{
|
||||||
char subdirname[13];
|
char subdirname[FILENAME_LENGTH];
|
||||||
strncpy(subdirname, dirname_start, dirname_end-dirname_start);
|
strncpy(subdirname, dirname_start, dirname_end-dirname_start);
|
||||||
subdirname[dirname_end-dirname_start]=0;
|
subdirname[dirname_end-dirname_start]=0;
|
||||||
SERIAL_ECHOLN(subdirname);
|
SERIAL_ECHOLN(subdirname);
|
||||||
|
@ -408,7 +408,7 @@ void CardReader::removeFile(char* name)
|
||||||
//SERIAL_ECHO("end :");SERIAL_ECHOLN((int)(dirname_end-name));
|
//SERIAL_ECHO("end :");SERIAL_ECHOLN((int)(dirname_end-name));
|
||||||
if(dirname_end>0 && dirname_end>dirname_start)
|
if(dirname_end>0 && dirname_end>dirname_start)
|
||||||
{
|
{
|
||||||
char subdirname[13];
|
char subdirname[FILENAME_LENGTH];
|
||||||
strncpy(subdirname, dirname_start, dirname_end-dirname_start);
|
strncpy(subdirname, dirname_start, dirname_end-dirname_start);
|
||||||
subdirname[dirname_end-dirname_start]=0;
|
subdirname[dirname_end-dirname_start]=0;
|
||||||
SERIAL_ECHOLN(subdirname);
|
SERIAL_ECHOLN(subdirname);
|
||||||
|
@ -510,7 +510,7 @@ void CardReader::checkautostart(bool force)
|
||||||
}
|
}
|
||||||
|
|
||||||
char autoname[30];
|
char autoname[30];
|
||||||
sprintf_P(autoname, PSTR("auto%i.g"), lastnr);
|
sprintf_P(autoname, PSTR("auto%i.g"), autostart_index);
|
||||||
for(int8_t i=0;i<(int8_t)strlen(autoname);i++)
|
for(int8_t i=0;i<(int8_t)strlen(autoname);i++)
|
||||||
autoname[i]=tolower(autoname[i]);
|
autoname[i]=tolower(autoname[i]);
|
||||||
dir_t p;
|
dir_t p;
|
||||||
|
@ -537,9 +537,9 @@ void CardReader::checkautostart(bool force)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(!found)
|
if(!found)
|
||||||
lastnr=-1;
|
autostart_index=-1;
|
||||||
else
|
else
|
||||||
lastnr++;
|
autostart_index++;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CardReader::closefile(bool store_location)
|
void CardReader::closefile(bool store_location)
|
||||||
|
|
|
@ -52,10 +52,10 @@ public:
|
||||||
bool logging;
|
bool logging;
|
||||||
bool sdprinting;
|
bool sdprinting;
|
||||||
bool cardOK;
|
bool cardOK;
|
||||||
char filename[13];
|
char filename[FILENAME_LENGTH];
|
||||||
char longFilename[LONG_FILENAME_LENGTH];
|
char longFilename[LONG_FILENAME_LENGTH];
|
||||||
bool filenameIsDir;
|
bool filenameIsDir;
|
||||||
int lastnr; //last number of the autostart;
|
int autostart_index;
|
||||||
private:
|
private:
|
||||||
SdFile root,*curDir,workDir,workDirParents[MAX_DIR_DEPTH];
|
SdFile root,*curDir,workDir,workDirParents[MAX_DIR_DEPTH];
|
||||||
uint16_t workDirDepth;
|
uint16_t workDirDepth;
|
||||||
|
@ -63,7 +63,7 @@ private:
|
||||||
SdVolume volume;
|
SdVolume volume;
|
||||||
SdFile file;
|
SdFile file;
|
||||||
#define SD_PROCEDURE_DEPTH 1
|
#define SD_PROCEDURE_DEPTH 1
|
||||||
#define MAXPATHNAMELENGTH (13*MAX_DIR_DEPTH+MAX_DIR_DEPTH+1)
|
#define MAXPATHNAMELENGTH (FILENAME_LENGTH*MAX_DIR_DEPTH+MAX_DIR_DEPTH+1)
|
||||||
uint8_t file_subcall_ctr;
|
uint8_t file_subcall_ctr;
|
||||||
uint32_t filespos[SD_PROCEDURE_DEPTH];
|
uint32_t filespos[SD_PROCEDURE_DEPTH];
|
||||||
char filenames[SD_PROCEDURE_DEPTH][MAXPATHNAMELENGTH];
|
char filenames[SD_PROCEDURE_DEPTH][MAXPATHNAMELENGTH];
|
||||||
|
|
|
@ -377,7 +377,7 @@ static void lcd_main_menu()
|
||||||
#ifdef SDSUPPORT
|
#ifdef SDSUPPORT
|
||||||
static void lcd_autostart_sd()
|
static void lcd_autostart_sd()
|
||||||
{
|
{
|
||||||
card.lastnr=0;
|
card.autostart_index=0;
|
||||||
card.setroot();
|
card.setroot();
|
||||||
card.checkautostart(true);
|
card.checkautostart(true);
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue