Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 9 additions & 14 deletions Marlin/SdBaseFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ int8_t SdBaseFile::lsPrintNext(uint8_t flags, uint8_t indent) {
// print size if requested
if (!DIR_IS_SUBDIR(&dir) && (flags & LS_SIZE)) {
SERIAL_CHAR(' ');
SERIAL_PROTOCOL(dir.fileSize);
SERIAL_ECHO(dir.fileSize);
}
SERIAL_EOL();
return DIR_IS_FILE(&dir) ? 1 : 2;
Expand Down Expand Up @@ -601,7 +601,7 @@ bool SdBaseFile::open(SdBaseFile* dirFile, const uint8_t dname[11], uint8_t ofla
// search for file

while (dirFile->curPosition_ < dirFile->fileSize_) {
index = 0XF & (dirFile->curPosition_ >> 5);
index = 0xF & (dirFile->curPosition_ >> 5);
p = dirFile->readDirCache();
if (!p) return false;

Expand Down Expand Up @@ -705,7 +705,7 @@ bool SdBaseFile::open(SdBaseFile* dirFile, uint16_t index, uint8_t oflag) {
return false;
}
// open cached entry
return openCachedEntry(index & 0XF, oflag);
return openCachedEntry(index & 0xF, oflag);
}

// open a cached directory entry. Assumes vol_ is initialized
Expand Down Expand Up @@ -775,7 +775,7 @@ bool SdBaseFile::openNext(SdBaseFile* dirFile, uint8_t oflag) {
vol_ = dirFile->vol_;

while (1) {
index = 0XF & (dirFile->curPosition_ >> 5);
index = 0xF & (dirFile->curPosition_ >> 5);

// read entry into cache
p = dirFile->readDirCache();
Expand Down Expand Up @@ -902,11 +902,10 @@ int SdBaseFile::peek() {
return c;
}


// print uint8_t with width 2
static void print2u(uint8_t v) {
static void print2u(const uint8_t v) {
if (v < 10) SERIAL_CHAR('0');
SERIAL_PRINT(v, DEC);
SERIAL_ECHO_F(v, DEC);
}

/**
Expand All @@ -927,7 +926,7 @@ static void print2u(uint8_t v) {
* \param[in] fatDate The date field from a directory entry.
*/
void SdBaseFile::printFatDate(uint16_t fatDate) {
SERIAL_PROTOCOL(FAT_YEAR(fatDate));
SERIAL_ECHO(FAT_YEAR(fatDate));
SERIAL_CHAR('-');
print2u(FAT_MONTH(fatDate));
SERIAL_CHAR('-');
Expand Down Expand Up @@ -959,7 +958,7 @@ void SdBaseFile::printFatTime(uint16_t fatTime) {
bool SdBaseFile::printName() {
char name[FILENAME_LENGTH];
if (!getFilename(name)) return false;
SERIAL_PROTOCOL(name);
SERIAL_ECHO(name);
return true;
}

Expand Down Expand Up @@ -1104,7 +1103,7 @@ dir_t* SdBaseFile::readDirCache() {
if (!isDir()) return 0;

// index of entry in cache
i = (curPosition_ >> 5) & 0XF;
i = (curPosition_ >> 5) & 0xF;

// use read to locate and cache block
if (read() < 0) return 0;
Expand Down Expand Up @@ -1726,8 +1725,4 @@ int16_t SdBaseFile::write(const void* buf, uint16_t nbyte) {
return -1;
}

#if ALLOW_DEPRECATED_FUNCTIONS
void (*SdBaseFile::oldDateTime_)(uint16_t &date, uint16_t &time) = 0;
#endif

#endif // SDSUPPORT
115 changes: 2 additions & 113 deletions Marlin/SdBaseFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
#include "SdFatConfig.h"
#include "SdVolume.h"

#include <stdint.h>

/**
* \struct filepos_t
* \brief internal type for istream
Expand Down Expand Up @@ -383,119 +385,6 @@ class SdBaseFile {
bool open(SdBaseFile* dirFile, const uint8_t dname[11], uint8_t oflag);
bool openCachedEntry(uint8_t cacheIndex, uint8_t oflags);
dir_t* readDirCache();

// Deprecated functions
#if ALLOW_DEPRECATED_FUNCTIONS
public:

/**
* \deprecated Use:
* bool contiguousRange(uint32_t* bgnBlock, uint32_t* endBlock);
* \param[out] bgnBlock the first block address for the file.
* \param[out] endBlock the last block address for the file.
* \return true for success or false for failure.
*/
bool contiguousRange(uint32_t& bgnBlock, uint32_t& endBlock) {
return contiguousRange(&bgnBlock, &endBlock);
}

/**
* \deprecated Use:
* bool createContiguous(SdBaseFile* dirFile, const char* path, uint32_t size)
* \param[in] dirFile The directory where the file will be created.
* \param[in] path A path with a valid DOS 8.3 file name.
* \param[in] size The desired file size.
* \return true for success or false for failure.
*/
bool createContiguous(SdBaseFile& dirFile, const char* path, uint32_t size) {
return createContiguous(&dirFile, path, size);
}

/**
* \deprecated Use:
* static void dateTimeCallback(
* void (*dateTime)(uint16_t* date, uint16_t* time));
* \param[in] dateTime The user's call back function.
*/
static void dateTimeCallback(
void (*dateTime)(uint16_t &date, uint16_t &time)) {
oldDateTime_ = dateTime;
dateTime_ = dateTime ? oldToNew : 0;
}

/**
* \deprecated Use:
* bool open(SdBaseFile* dirFile, const char* path, uint8_t oflag);
* \param[in] dirFile An open SdFat instance for the directory containing the
* file to be opened.
* \param[in] path A path with a valid 8.3 DOS name for the file.
* \param[in] oflag Values for \a oflag are constructed by a bitwise-inclusive
* OR of flags O_READ, O_WRITE, O_TRUNC, and O_SYNC.
* \return true for success or false for failure.
*/
bool open(SdBaseFile& dirFile, const char* path, uint8_t oflag) {
return open(&dirFile, path, oflag);
}

/**
* \deprecated Do not use in new apps
* \param[in] dirFile An open SdFat instance for the directory containing the
* file to be opened.
* \param[in] path A path with a valid 8.3 DOS name for a file to be opened.
* \return true for success or false for failure.
*/
bool open(SdBaseFile& dirFile, const char* path) {
return open(dirFile, path, O_RDWR);
}

/**
* \deprecated Use:
* bool open(SdBaseFile* dirFile, uint16_t index, uint8_t oflag);
* \param[in] dirFile An open SdFat instance for the directory.
* \param[in] index The \a index of the directory entry for the file to be
* opened. The value for \a index is (directory file position)/32.
* \param[in] oflag Values for \a oflag are constructed by a bitwise-inclusive
* OR of flags O_READ, O_WRITE, O_TRUNC, and O_SYNC.
* \return true for success or false for failure.
*/
bool open(SdBaseFile& dirFile, uint16_t index, uint8_t oflag) {
return open(&dirFile, index, oflag);
}

/**
* \deprecated Use: bool openRoot(SdVolume* vol);
* \param[in] vol The FAT volume containing the root directory to be opened.
* \return true for success or false for failure.
*/
bool openRoot(SdVolume& vol) { return openRoot(&vol); }

/**
* \deprecated Use: int8_t readDir(dir_t* dir);
* \param[out] dir The dir_t struct that will receive the data.
* \return bytes read for success zero for eof or -1 for failure.
*/
int8_t readDir(dir_t& dir, char* longFilename) {
return readDir(&dir, longFilename);
}

/**
* \deprecated Use:
* static uint8_t remove(SdBaseFile* dirFile, const char* path);
* \param[in] dirFile The directory that contains the file.
* \param[in] path The name of the file to be removed.
* \return true for success or false for failure.
*/
static bool remove(SdBaseFile& dirFile, const char* path) { return remove(&dirFile, path); }

private:
static void (*oldDateTime_)(uint16_t &date, uint16_t &time);
static void oldToNew(uint16_t * const date, uint16_t * const time) {
uint16_t d, t;
oldDateTime_(d, t);
*date = d;
*time = t;
}
#endif // ALLOW_DEPRECATED_FUNCTIONS
};

#endif // _SDBASEFILE_H_
5 changes: 0 additions & 5 deletions Marlin/SdFatConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,6 @@
*/
#define ENDL_CALLS_FLUSH 0

/**
* Allow use of deprecated functions if ALLOW_DEPRECATED_FUNCTIONS is nonzero
*/
#define ALLOW_DEPRECATED_FUNCTIONS 1

/**
* Allow FAT12 volumes if FAT12_SUPPORT is nonzero.
* FAT12 has not been well tested.
Expand Down
2 changes: 1 addition & 1 deletion Marlin/SdVolume.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ bool SdVolume::fatPut(uint32_t cluster, uint32_t value) {
index &= 0x1FF;
uint8_t tmp = value;
if (cluster & 1) {
tmp = (cacheBuffer_.data[index] & 0XF) | tmp << 4;
tmp = (cacheBuffer_.data[index] & 0xF) | tmp << 4;
}
cacheBuffer_.data[index] = tmp;
index++;
Expand Down
Loading