tokio-fs-ext 0.3.8

Extend tokio fs to be compatible with native and wasm
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use std::io;

use super::opfs::{CreateFileMode, SyncAccessMode};
use crate::fs::opfs::{open_dir, open_file};

pub async fn try_exists(path: impl AsRef<std::path::Path>) -> io::Result<bool> {
    Ok(open_file(
        &path,
        CreateFileMode::NotCreate,
        false,
        SyncAccessMode::Readonly,
    )
    .await
    .is_ok()
        || open_dir(path, super::opfs::OpenDirType::NotCreate)
            .await
            .is_ok())
}