Преглед на файлове

add:添加luat_fs_dexist实现

Dozingfiretruck преди 7 месеца
родител
ревизия
59b7b92208
променени са 1 файла, в които са добавени 20 реда и са изтрити 0 реда
  1. 20 0
      luat/vfs/luat_vfs.c

+ 20 - 0
luat/vfs/luat_vfs.c

@@ -354,6 +354,24 @@ int luat_fs_lsdir(char const* _DirName, luat_fs_dirent_t* ents, size_t offset, s
     return ret;
 }
 
+int luat_fs_dexist(const char *_DirName){
+    // LLOGD("dexist? %s", _DirName);
+    luat_vfs_mount_t *mount = getmount(_DirName);
+    if (mount == NULL) {
+        LLOGD("no such mount");
+        return 0;
+    }
+    if (mount->fs->opts.opendir == NULL) {
+        LLOGD("such mount not support opendir");
+        return 0;
+    }
+    void* dir = mount->fs->opts.opendir(mount->userdata, _DirName + strlen(mount->prefix));
+    // LLOGD("opendir dir:%p",dir);
+    mount->fs->opts.closedir(mount->userdata,dir);
+    return dir == NULL ? 0 : -1;
+}
+
+
 void* luat_fs_mmap(FILE* stream) {
     luat_vfs_fd_t* fd = getfd(stream);
     if (fd == NULL)
@@ -387,4 +405,6 @@ int luat_fs_fflush(FILE *stream) {
     return -1;
 }
 
+
+
 #endif