!212 littlefs stat 接口支持获取文件类型
Merge pull request !212 from LeonChan/little-stat
This commit is contained in:
commit
2e621bc323
|
@ -743,6 +743,11 @@ int LfsStat(const char *path, struct stat *buf)
|
||||||
ret = lfs_stat(&(fileOpInfo->lfsInfo), path, &info);
|
ret = lfs_stat(&(fileOpInfo->lfsInfo), path, &info);
|
||||||
if (ret == 0) {
|
if (ret == 0) {
|
||||||
buf->st_size = info.size;
|
buf->st_size = info.size;
|
||||||
|
if (info.type == LFS_TYPE_REG) {
|
||||||
|
buf->st_mode = S_IFREG;
|
||||||
|
} else {
|
||||||
|
buf->st_mode = S_IFDIR;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
errno = LittlefsErrno(ret);
|
errno = LittlefsErrno(ret);
|
||||||
ret = VFS_ERROR;
|
ret = VFS_ERROR;
|
||||||
|
|
Loading…
Reference in New Issue