std::vector<Tial::VFS::NativeFSDriver::FileEntry> Tial::VFS::NativeFSDriver::listDirectory(const Path &path) { Utility::NativePath realPath = nativeDirectory/path; LOGN1 << "path = " << path << ", native path = " << realPath; std::vector<Tial::VFS::NativeFSDriver::FileEntry> v; #if (BOOST_OS_UNIX || BOOST_OS_MACOS) std::unique_ptr<DIR, std::function<void(DIR*)>> realDirectory( ::opendir(std::string(realPath).c_str()), [](DIR *ptr) { ::closedir(ptr); } ); if(!realDirectory) THROW std::system_error(errno, std::system_category()); struct dirent *entry; while((entry = ::readdir(realDirectory.get()))) { std::string name(entry->d_name); if(name == "." || name == "..") continue; v.push_back({name, entry->d_type == DT_DIR}); } #else #error "Platform not supported" #endif return v; }
virtual Status Mount(const VfsPath& mountPoint, const OsPath& path, size_t flags /* = 0 */, size_t priority /* = 0 */) { ScopedLock s; if(!DirectoryExists(path)) { if(flags & VFS_MOUNT_MUST_EXIST) return ERR::VFS_DIR_NOT_FOUND; // NOWARN else RETURN_STATUS_IF_ERR(CreateDirectories(path, 0700)); } VfsDirectory* directory; WARN_RETURN_STATUS_IF_ERR(vfs_Lookup(mountPoint, &m_rootDirectory, directory, 0, VFS_LOOKUP_ADD|VFS_LOOKUP_SKIP_POPULATE)); PRealDirectory realDirectory(new RealDirectory(path, priority, flags)); RETURN_STATUS_IF_ERR(vfs_Attach(directory, realDirectory)); return INFO::OK; }