Explorar el Código

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

Wendal Chen hace 2 años
padre
commit
93f0600407
Se han modificado 1 ficheros con 6 adiciones y 1 borrados
  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 --;
             }