Go Down

Topic: SDFat directory navigation questions (Read 262 times) previous topic - next topic

adwsystems

Dec 25, 2019, 01:36 am Last Edit: Dec 25, 2019, 02:19 am by adwsystems
1. My CD Card has the directories test1, test2, and test3. If I use chdir to enter test2. What function do I call to return the current directory?

2. How do I go up one directory? In DOS you enter "cd ..". I want to do the same thing. I figured how to go to the root (equivalent to "cd \"). I'm looking to just move up one directory level.

3. I would also like to move a file to a directory. I cannot find a move command in SDFat. Any idea appreciated.

Edit: I found this code in related to renaming files. Kind of an aside but might be the answer to #3.
snprintf(rname, sizeof(rname), "file%d.ext", ifile);
snprintf(dname, sizeof(dname), "dir/file%d.ext", ifile);
if (!sd.rename(rname, dname)) error("rename failed");

Is moving a file, just renaming the file with a different path?

Juraj

:-)
the concept of a current folder is the concept of the OS, not of the FS.
so your code must have a variable to remember the current folder.

adwsystems

#2
Dec 25, 2019, 02:19 pm Last Edit: Dec 25, 2019, 03:02 pm by adwsystems
:-)
the concept of a current folder is the concept of the OS, not of the FS.
so your code must have a variable to remember the current folder.
Please review the SDFat library, the documentation indicates contrary but does not have an example on how to.
Quote
SdFat has a current working directory, cwd, that is used to resolve paths for file.open() calls.

For a single SD card the current working directory is always the volume working directory for that card.
How do I print the current working directory from a call to file.cwd(); where SdFile file?

adwsystems

Has anyone tried to use the file.cwd() command in the SD library? I'm out of ideas on how to use it. I have not found any examples that include it.

Go Up