Parcourir la source

fix: vfs_posix实现的lsdir函数没有区分文件和目录

Wendal Chen il y a 2 ans
Parent
commit
93f0600407
1 fichiers modifiés avec 6 ajouts et 1 suppressions
  1. 6 1
      luat/vfs/luat_fs_posix.c

+ 6 - 1
luat/vfs/luat_fs_posix.c

@@ -250,7 +250,12 @@ int luat_vfs_posix_lsdir(void* fsdata, char const* _DirName, luat_fs_dirent_t* e
             }
             if (len > 0) {
                 memcpy(ents[index].d_name, ep->d_name, strlen(ep->d_name) + 1);
-                ents[index].d_type = 0;
+                if (ep->d_type == DT_REG) {
+                    ents[index].d_type = 0;
+                }
+                else {
+                    ents[index].d_type = 1;
+                }
                 index++;
                 len --;
             }