| #define MAX_COMPONENT_LEN 12 // What is max length? | #define MAX_COMPONENT_LEN 12 // What is max length? | ||||
| #define PATH_COMPONENT_BUFFER_LEN MAX_COMPONENT_LEN+1 | #define PATH_COMPONENT_BUFFER_LEN MAX_COMPONENT_LEN+1 | ||||
| bool getNextPathComponent(char *path, unsigned int *p_offset, | |||||
| bool getNextPathComponent(const char *path, unsigned int *p_offset, | |||||
| char *buffer) { | char *buffer) { | ||||
| /* | /* | ||||
| boolean walkPath(char *filepath, SdFile& parentDir, | |||||
| boolean walkPath(const char *filepath, SdFile& parentDir, | |||||
| boolean (*callback)(SdFile& parentDir, | boolean (*callback)(SdFile& parentDir, | ||||
| char *filePathComponent, | char *filePathComponent, | ||||
| boolean isLastComponent, | boolean isLastComponent, | ||||
| //} | //} | ||||
| boolean SDClass::exists(char *filepath) { | |||||
| boolean SDClass::exists(const char *filepath) { | |||||
| /* | /* | ||||
| Returns true if the supplied file path exists. | Returns true if the supplied file path exists. | ||||
| //} | //} | ||||
| boolean SDClass::mkdir(char *filepath) { | |||||
| boolean SDClass::mkdir(const char *filepath) { | |||||
| /* | /* | ||||
| Makes a single directory or a heirarchy of directories. | Makes a single directory or a heirarchy of directories. | ||||
| return walkPath(filepath, root, callback_makeDirPath); | return walkPath(filepath, root, callback_makeDirPath); | ||||
| } | } | ||||
| boolean SDClass::rmdir(char *filepath) { | |||||
| boolean SDClass::rmdir(const char *filepath) { | |||||
| /* | /* | ||||
| Makes a single directory or a heirarchy of directories. | Makes a single directory or a heirarchy of directories. | ||||
| return walkPath(filepath, root, callback_rmdir); | return walkPath(filepath, root, callback_rmdir); | ||||
| } | } | ||||
| boolean SDClass::remove(char *filepath) { | |||||
| boolean SDClass::remove(const char *filepath) { | |||||
| return walkPath(filepath, root, callback_remove); | return walkPath(filepath, root, callback_remove); | ||||
| } | } | ||||
| File open(const char *filename, uint8_t mode = FILE_READ); | File open(const char *filename, uint8_t mode = FILE_READ); | ||||
| // Methods to determine if the requested file path exists. | // Methods to determine if the requested file path exists. | ||||
| boolean exists(char *filepath); | |||||
| boolean exists(const char *filepath); | |||||
| // Create the requested directory heirarchy--if intermediate directories | // Create the requested directory heirarchy--if intermediate directories | ||||
| // do not exist they will be created. | // do not exist they will be created. | ||||
| boolean mkdir(char *filepath); | |||||
| boolean mkdir(const char *filepath); | |||||
| // Delete the file. | // Delete the file. | ||||
| boolean remove(char *filepath); | |||||
| boolean remove(const char *filepath); | |||||
| boolean rmdir(char *filepath); | |||||
| boolean rmdir(const char *filepath); | |||||
| private: | private: | ||||
| while (!(SPI0_SR & SPI_SR_TCF)) {} | while (!(SPI0_SR & SPI_SR_TCF)) {} | ||||
| } | } | ||||
| /** SPI send multiple bytes */ | /** SPI send multiple bytes */ | ||||
| #if 0 | |||||
| static void spiSend(const uint8_t* output, size_t len) { | static void spiSend(const uint8_t* output, size_t len) { | ||||
| // clear any data in RX FIFO | // clear any data in RX FIFO | ||||
| SPI0_MCR = SPI_MCR_MSTR | SPI_MCR_CLR_RXF | SPI_MCR_PCSIS(0x1F); | SPI0_MCR = SPI_MCR_MSTR | SPI_MCR_CLR_RXF | SPI_MCR_PCSIS(0x1F); | ||||
| nf--; | nf--; | ||||
| } | } | ||||
| } | } | ||||
| #endif | |||||
| */ | */ | ||||
| uint8_t Sd2Card::readData(uint32_t block, | uint8_t Sd2Card::readData(uint32_t block, | ||||
| uint16_t offset, uint16_t count, uint8_t* dst) { | uint16_t offset, uint16_t count, uint8_t* dst) { | ||||
| uint16_t n; | |||||
| //uint16_t n; | |||||
| if (count == 0) return true; | if (count == 0) return true; | ||||
| if ((count + offset) > 512) { | if ((count + offset) > 512) { | ||||
| goto fail; | goto fail; |
| if (!f.remove()) return false; | if (!f.remove()) return false; | ||||
| } | } | ||||
| // position to next entry if required | // position to next entry if required | ||||
| if (curPosition_ != (32*(index + 1))) { | |||||
| if (curPosition_ != (uint32_t)(32*(index + 1))) { | |||||
| if (!seekSet(32*(index + 1))) return false; | if (!seekSet(32*(index + 1))) return false; | ||||
| } | } | ||||
| } | } |