1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-07-30 16:24:09 +03:00

Adding SD.remove(file) and another example.

This commit is contained in:
David A. Mellis
2010-11-20 13:07:59 -05:00
parent 5af5619df4
commit 6f0ea10600
3 changed files with 53 additions and 4 deletions

View File

@ -294,10 +294,9 @@ boolean callback_openPath(SdFile& parentDir, char *filePathComponent,
*/
if (isLastComponent) {
SDClass *p_MemoryCard = static_cast<SDClass*>(object);
p_MemoryCard->file.open(parentDir, filePathComponent,
p_MemoryCard->fileOpenMode);
p_MemoryCard->c = -1;
SDClass *p_SD = static_cast<SDClass*>(object);
p_SD->file.open(parentDir, filePathComponent, p_SD->fileOpenMode);
p_SD->c = -1;
// TODO: Return file open result?
return false;
}
@ -305,6 +304,16 @@ boolean callback_openPath(SdFile& parentDir, char *filePathComponent,
}
boolean callback_remove(SdFile& parentDir, char *filePathComponent,
boolean isLastComponent, void *object) {
if (isLastComponent) {
SdFile::remove(parentDir, filePathComponent);
return false;
}
return true;
}
/* Implementation of class used to create `SDCard` object. */
@ -415,4 +424,8 @@ boolean SDClass::mkdir(char *filepath) {
return walkPath(filepath, root, callback_makeDirPath);
}
void SDClass::remove(char *filepath) {
walkPath(filepath, root, callback_remove);
}
SDClass SD;