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:
@ -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;
|
Reference in New Issue
Block a user