Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 2 of 2

Thread: rmRfStar(): How can I use it?

  1. #1

    rmRfStar(): How can I use it?

    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:
    Code:
      File root = SD.open("/");
      while (true) {
        File entry = root.openNextFile();
        if (!entry) {
          // no more files
          break;
        }
        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.

    Uwe.
    Last edited by Uwe; 09-21-2021 at 06:31 AM.

  2. #2
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    9,561
    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...orage.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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •