|
|
@ -17,8 +17,9 @@ |
|
|
|
* along with the Arduino SdFat Library. If not, see |
|
|
|
* <http://www.gnu.org/licenses/>.
|
|
|
|
*/ |
|
|
|
#include "SdFat.h" |
|
|
|
#include <Print.h> |
|
|
|
|
|
|
|
#include "Marlin.h" |
|
|
|
#ifdef SDSUPPORT |
|
|
|
|
|
|
|
#include "SdBaseFile.h" |
|
|
|
//------------------------------------------------------------------------------
|
|
|
@ -314,14 +315,14 @@ void SdBaseFile::getpos(fpos_t* pos) { |
|
|
|
* \param[in] indent Amount of space before file name. Used for recursive |
|
|
|
* list to indicate subdirectory level. |
|
|
|
*/ |
|
|
|
void SdBaseFile::ls(Print *p, uint8_t flags, uint8_t indent) { |
|
|
|
void SdBaseFile::ls(uint8_t flags, uint8_t indent) { |
|
|
|
rewind(); |
|
|
|
int8_t status; |
|
|
|
while ((status = lsPrintNext( p, flags, indent))) { |
|
|
|
while ((status = lsPrintNext( flags, indent))) { |
|
|
|
if (status > 1 && (flags & LS_R)) { |
|
|
|
uint16_t index = curPosition()/32 - 1; |
|
|
|
SdBaseFile s; |
|
|
|
if (s.open(this, index, O_READ)) s.ls( p, flags, indent + 2); |
|
|
|
if (s.open(this, index, O_READ)) s.ls( flags, indent + 2); |
|
|
|
seekSet(32 * (index + 1)); |
|
|
|
} |
|
|
|
} |
|
|
@ -329,8 +330,7 @@ void SdBaseFile::ls(Print *p, uint8_t flags, uint8_t indent) { |
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
// saves 32 bytes on stack for ls recursion
|
|
|
|
// return 0 - EOF, 1 - normal file, or 2 - directory
|
|
|
|
int8_t SdBaseFile::lsPrintNext( Print *p, uint8_t flags, uint8_t indent) { |
|
|
|
Print &MYSERIAL = *p; |
|
|
|
int8_t SdBaseFile::lsPrintNext( uint8_t flags, uint8_t indent) { |
|
|
|
dir_t dir; |
|
|
|
uint8_t w = 0; |
|
|
|
|
|
|
@ -365,9 +365,9 @@ int8_t SdBaseFile::lsPrintNext( Print *p, uint8_t flags, uint8_t indent) { |
|
|
|
// print modify date/time if requested
|
|
|
|
if (flags & LS_DATE) { |
|
|
|
MYSERIAL.write(' '); |
|
|
|
printFatDate( p, dir.lastWriteDate); |
|
|
|
printFatDate( dir.lastWriteDate); |
|
|
|
MYSERIAL.write(' '); |
|
|
|
printFatTime( p, dir.lastWriteTime); |
|
|
|
printFatTime( dir.lastWriteTime); |
|
|
|
} |
|
|
|
// print size if requested
|
|
|
|
if (!DIR_IS_SUBDIR(&dir) && (flags & LS_SIZE)) { |
|
|
@ -939,8 +939,8 @@ int SdBaseFile::peek() { |
|
|
|
* \param[in] width Blank fill name if length is less than \a width. |
|
|
|
* \param[in] printSlash Print '/' after directory names if true. |
|
|
|
*/ |
|
|
|
void SdBaseFile::printDirName(Print *p, const dir_t& dir, uint8_t width, bool printSlash) { |
|
|
|
Print &MYSERIAL = *p; |
|
|
|
void SdBaseFile::printDirName(const dir_t& dir, |
|
|
|
uint8_t width, bool printSlash) { |
|
|
|
uint8_t w = 0; |
|
|
|
for (uint8_t i = 0; i < 11; i++) { |
|
|
|
if (dir.name[i] == ' ')continue; |
|
|
@ -962,8 +962,7 @@ void SdBaseFile::printDirName(Print *p, const dir_t& dir, uint8_t width, bool pr |
|
|
|
} |
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
// print uint8_t with width 2
|
|
|
|
static void print2u( Print *p, uint8_t v) { |
|
|
|
Print &MYSERIAL = *p; |
|
|
|
static void print2u( uint8_t v) { |
|
|
|
if (v < 10) MYSERIAL.write('0'); |
|
|
|
MYSERIAL.print(v, DEC); |
|
|
|
} |
|
|
@ -983,14 +982,12 @@ static void print2u( Print *p, uint8_t v) { |
|
|
|
* \param[in] pr Print stream for output. |
|
|
|
* \param[in] fatDate The date field from a directory entry. |
|
|
|
*/ |
|
|
|
void SdBaseFile::printFatDate(Print *p, uint16_t fatDate) { |
|
|
|
Print &MYSERIAL = *p; |
|
|
|
|
|
|
|
void SdBaseFile::printFatDate(uint16_t fatDate) { |
|
|
|
MYSERIAL.print(FAT_YEAR(fatDate)); |
|
|
|
MYSERIAL.write('-'); |
|
|
|
print2u( p, FAT_MONTH(fatDate)); |
|
|
|
print2u( FAT_MONTH(fatDate)); |
|
|
|
MYSERIAL.write('-'); |
|
|
|
print2u( p, FAT_DAY(fatDate)); |
|
|
|
print2u( FAT_DAY(fatDate)); |
|
|
|
} |
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
@ -1001,14 +998,12 @@ void SdBaseFile::printFatDate(Print *p, uint16_t fatDate) { |
|
|
|
* \param[in] pr Print stream for output. |
|
|
|
* \param[in] fatTime The time field from a directory entry. |
|
|
|
*/ |
|
|
|
void SdBaseFile::printFatTime( Print *p, uint16_t fatTime) { |
|
|
|
Print &MYSERIAL = *p; |
|
|
|
|
|
|
|
print2u( p, FAT_HOUR(fatTime)); |
|
|
|
void SdBaseFile::printFatTime( uint16_t fatTime) { |
|
|
|
print2u( FAT_HOUR(fatTime)); |
|
|
|
MYSERIAL.write(':'); |
|
|
|
print2u( p, FAT_MINUTE(fatTime)); |
|
|
|
print2u( FAT_MINUTE(fatTime)); |
|
|
|
MYSERIAL.write(':'); |
|
|
|
print2u( p, FAT_SECOND(fatTime)); |
|
|
|
print2u( FAT_SECOND(fatTime)); |
|
|
|
} |
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
/** Print a file's name to Serial
|
|
|
@ -1016,8 +1011,7 @@ void SdBaseFile::printFatTime( Print *p, uint16_t fatTime) { |
|
|
|
* \return The value one, true, is returned for success and |
|
|
|
* the value zero, false, is returned for failure. |
|
|
|
*/ |
|
|
|
bool SdBaseFile::printName(Print *p) { |
|
|
|
Print &MYSERIAL = *p; |
|
|
|
bool SdBaseFile::printName() { |
|
|
|
char name[13]; |
|
|
|
if (!getFilename(name)) return false; |
|
|
|
MYSERIAL.print(name); |
|
|
@ -1826,3 +1820,6 @@ int16_t SdBaseFile::write(const void* buf, uint16_t nbyte) { |
|
|
|
#if ALLOW_DEPRECATED_FUNCTIONS && !defined(DOXYGEN) |
|
|
|
void (*SdBaseFile::oldDateTime_)(uint16_t& date, uint16_t& time) = 0; // NOLINT
|
|
|
|
#endif // ALLOW_DEPRECATED_FUNCTIONS
|
|
|
|
|
|
|
|
|
|
|
|
#endif |