rmRfStar(): How can I use it?

Not open for further replies.


Active member
I want to write a function that removes all directories(including subdirectories and files) from my SD card.
And there is a build-in function for this called "rmRfStar()".
But I'm too silly to use it.
Maybe one can help me out....

That is my code so far:
  File root = SD.open("/");
  while (true) {
    File entry = root.openNextFile();
    if (!entry) {
      // no more files
    if (entry.isDirectory()) {
      // now delete it
      // how to convert "File" into "SdFile"?
      SdFile sdf;
      uint8_t result = sdf.open(&sdf, entry.name(), O_RDONLY);
      Serial.println(result); // => 0
      result = sdf.rmRfStar();
      Serial.println(result); // => 0

I'm able to find all the directories I want to delete but I'm stuck on how to make my way from "File" type to "SdFile".
All the Arduino examples I found use rmRfStar() directly from the "File" object but Teensy seems to not support that.

Last edited:
Sorry, maybe hard to get there from here...

As far as I can tell rmRfStar is only contained within fatfile.h and fatfile.cpp. It is not included in any of the other things like ExFat, nor is it in keywords...

The only way I know to get there is to SDFat instead of SD library... And configure for FatFile...

I could be wrong...

Note: that functionality can of course be written. MTP code that we are playing with has functions for doing this. It has a few abstractions on it,
but it uses a recursive call to do the work.
That version is up at: https://github.com/KurtE/MTP_t4/blob/FS_Integration/src/Storage.cpp#L464

Also side note, some of us are working on integrating some additional FS capabilities. Included with some of our stuff, we have built in some of the SD Format sketch into our PFSLib which currently is part of MSC library work, such that you could simply open up your partition and call a format function to initialize the disk... But none of this code is currently finalized nor any build... But hopefullly.
Not open for further replies.