To get the current working directory, use
f_getcwd(TCHAR *, UINT);
To use this function, we have to change the configuration in conf_fatfs.h. Set #define _FS_RPATH to 2. '
To open a dir,
f_opendir(DIR*, const TCHAR *);
Declare the 2nd parameter as a array and not a pointer, i.e
const TCHAR path[100];
//const TCHAR *path;
To get a pointer to a directory object,
f_opendir (DIR*, const TCHAR*);
and to read a directory item,
f_readdir (DIR*, FILINFO*);
f_readdir return FR_OK when it successfully reads an item.
Note: remember to initialize the variables for DIR and FILINFO to 0 using memset.