Sha256: 56081d541caadca0fc59e84d55e78e702fe9373679598016224ad0b072b189a7

Contents?: true

Size: 1.73 KB

Versions: 19

Compression:

Stored size: 1.73 KB

Contents

use crate::fs::asyncify;

use std::io;
use std::path::Path;

/// Recursively creates a directory and all of its parent components if they
/// are missing.
///
/// This is an async version of [`std::fs::create_dir_all`][std]
///
/// [std]: std::fs::create_dir_all
///
/// # Platform-specific behavior
///
/// This function currently corresponds to the `mkdir` function on Unix
/// and the `CreateDirectory` function on Windows.
/// Note that, this [may change in the future][changes].
///
/// [changes]: https://doc.rust-lang.org/std/io/index.html#platform-specific-behavior
///
/// # Errors
///
/// This function will return an error in the following situations, but is not
/// limited to just these cases:
///
/// * If any directory in the path specified by `path` does not already exist
/// and it could not be created otherwise. The specific error conditions for
/// when a directory is being created (after it is determined to not exist) are
/// outlined by [`fs::create_dir`].
///
/// Notable exception is made for situations where any of the directories
/// specified in the `path` could not be created as it was being created concurrently.
/// Such cases are considered to be successful. That is, calling `create_dir_all`
/// concurrently from multiple threads or processes is guaranteed not to fail
/// due to a race condition with itself.
///
/// [`fs::create_dir`]: std::fs::create_dir
///
/// # Examples
///
/// ```no_run
/// use tokio::fs;
///
/// #[tokio::main]
/// async fn main() -> std::io::Result<()> {
///     fs::create_dir_all("/some/dir").await?;
///     Ok(())
/// }
/// ```
pub async fn create_dir_all(path: impl AsRef<Path>) -> io::Result<()> {
    let path = path.as_ref().to_owned();
    asyncify(move || std::fs::create_dir_all(path)).await
}

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
wasmtime-14.0.4 ./ext/cargo-vendor/tokio-1.33.0/src/fs/create_dir_all.rs
wasmtime-14.0.3 ./ext/cargo-vendor/tokio-1.33.0/src/fs/create_dir_all.rs
wasmtime-14.0.1 ./ext/cargo-vendor/tokio-1.33.0/src/fs/create_dir_all.rs
wasmtime-14.0.0 ./ext/cargo-vendor/tokio-1.33.0/src/fs/create_dir_all.rs
wasmtime-13.0.0 ./ext/cargo-vendor/tokio-1.32.0/src/fs/create_dir_all.rs
wasmtime-12.0.1 ./ext/cargo-vendor/tokio-1.32.0/src/fs/create_dir_all.rs
wasmtime-12.0.0 ./ext/cargo-vendor/tokio-1.32.0/src/fs/create_dir_all.rs
wasmtime-11.0.0 ./ext/cargo-vendor/tokio-1.32.0/src/fs/create_dir_all.rs
wasmtime-10.0.1 ./ext/cargo-vendor/tokio-1.30.0/src/fs/create_dir_all.rs
wasmtime-10.0.0 ./ext/cargo-vendor/tokio-1.30.0/src/fs/create_dir_all.rs
wasmtime-9.0.4 ./ext/cargo-vendor/tokio-1.30.0/src/fs/create_dir_all.rs
wasmtime-9.0.1 ./ext/cargo-vendor/tokio-1.28.1/src/fs/create_dir_all.rs
wasmtime-8.0.0 ./ext/cargo-vendor/tokio-1.27.0/src/fs/create_dir_all.rs
wasmtime-7.0.0 ./ext/cargo-vendor/tokio-1.27.0/src/fs/create_dir_all.rs
wasmtime-6.0.1 ./ext/cargo-vendor/tokio-1.25.0/src/fs/create_dir_all.rs
wasmtime-6.0.0 ./ext/cargo-vendor/tokio-1.25.0/src/fs/create_dir_all.rs
wasmtime-5.0.0 ./ext/cargo-vendor/tokio-1.24.2/src/fs/create_dir_all.rs
wasmtime-0.4.1 ./ext/cargo-vendor/tokio-1.23.0/src/fs/create_dir_all.rs
wasmtime-0.4.0 ./ext/cargo-vendor/tokio-1.23.0/src/fs/create_dir_all.rs