Working Directory Functions - POSIX
Normally, all file or directory paths must be absolute, either on the default volume or on an explicitly-specified volume:
p_file1 = fs_fopen("\\file.txt", "r"); /* File on default volume */ p_file2 = fs_fopen("sdcard:0:\\file.txt", "r"); /* File on explicitly-specified volume */
If working directory functionality is enabled, paths may be specified relative to the working directory of the current task:
p_file2 = fs_fopen("file.txt", "r"); /* File in working directory */ p_file1 = fs_fopen("..\\file.txt", "r"); /* File in parent of working directory */
The two standard special path components are supported. The path component “..” moves to the parent of the current working directory. The path component “.” makes no change; essentially, it means the current working directory.
fs_chdir()
is used to set the working directory. If a relative path is employed before any working directory is set, the root directory of the default volume is used.
The application can get the working directory with fs_getcwd()
. A terminal interface may use this function to implement an equivalent to the standard pwd (print working directory) command, while calling fs_chdir()
to carry out a cd operation. If working directories are enabled, the µC/Shell commands for µC/FS manipulate and access the working directory with fs_chdir()
and fs_getcwd()
(see also Shell Commands).