tokio_fs_ext/fs/wasm/
try_exists.rs

1use std::io;
2
3use super::opfs::{CreateFileMode, SyncAccessMode, open_dir, open_file};
4
5pub async fn try_exists(path: impl AsRef<std::path::Path>) -> io::Result<bool> {
6    Ok(open_file(
7        &path,
8        CreateFileMode::NotCreate,
9        SyncAccessMode::Readonly,
10        false,
11    )
12    .await
13    .is_ok()
14        || open_dir(path, super::opfs::OpenDirType::NotCreate)
15            .await
16            .is_ok())
17}