littlefs-project / littlefs

A little fail-safe filesystem designed for microcontrollers
BSD 3-Clause "New" or "Revised" License
5.25k stars 804 forks source link

lfs.c:Support get file path #975

Closed crafcat7 closed 7 months ago

crafcat7 commented 7 months ago

I added two new interfaces to obtain the path of the file/folder.

int lfs_dir_path(lfs_t *lfs, lfs_dir_t *dir, char *path, lfs_size_t size);
int lfs_file_path(lfs_t *lfs, lfs_file_t *file, char *path, lfs_size_t size);

Mainly rely on a new internal interface, to a recursive search target

static lfs_ssize_t lfs_dir_path_(lfs_t *lfs,
         lfs_mdir_t *dir, uint16_t id, char *path, lfs_size_t size)
crafcat7 commented 7 months ago

Modify the local commit branch and merge the new PR to https://github.com/littlefs-project/littlefs/pull/976