SdFat icon indicating copy to clipboard operation
SdFat copied to clipboard

did cwd() displear in v2x

Open rickyelqasem opened this issue 4 years ago • 3 comments

I needed to update to later version on sdfat to support other library but when I do cwd doesn't work.. and the ide complains its not a member of file.

rickyelqasem avatar Apr 05 '21 14:04 rickyelqasem

There no longer is a single global cwd object since there are now three basic file/volume types. Each type has a current working volume and each volume has a working directory.

You can do this:

  ExFat sd;
  ExFile file;
 
  // Change exFAT current working volume to sd and volume working directory for sd to "Recipes/Pasta".
  sd.chdir("Recipes/Pasta");

  // Open "Recipes/Pasta/Farfalle.txt" on sd for read.
  file.open("Farfalle.txt");

How were you using cwd()?

greiman avatar Apr 05 '21 18:04 greiman

I cannot remember now but I think from my code I was going to the top of the CWD so I can start my file:

sd.chdir(path); file.cwd()->rewind();

filecount = 0; while (file.openNext(file.cwd(), O_RDONLY)) {

rickyelqasem avatar Apr 05 '21 19:04 rickyelqasem

Just do this:

  File dir;
  File file;

  dir.open(path);
  dir.rewind();

  while (file.openNext(&dir, O_RDONLY)) {

greiman avatar Apr 05 '21 19:04 greiman