littlefs-project / littlefs

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

lfs.c:Support get file path #975

Closed crafcat7 closed 2 months ago

crafcat7 commented 2 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 2 months ago

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