Sha256: 233cbab2579a787614aeee88845a57f1578e9c2e064a3456c799f61430e911ad

Contents?: true

Size: 1.52 KB

Versions: 19

Compression:

Stored size: 1.52 KB

Contents

use crate::fs::asyncify;

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

/// Creates a new, empty directory at the provided path.
///
/// This is an async version of [`std::fs::create_dir`][std]
///
/// [std]: std::fs::create_dir
///
/// # 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
///
/// **NOTE**: If a parent of the given path doesn't exist, this function will
/// return an error. To create a directory and all its missing parents at the
/// same time, use the [`create_dir_all`] function.
///
/// # Errors
///
/// This function will return an error in the following situations, but is not
/// limited to just these cases:
///
/// * User lacks permissions to create directory at `path`.
/// * A parent of the given path doesn't exist. (To create a directory and all
///   its missing parents at the same time, use the [`create_dir_all`]
///   function.)
/// * `path` already exists.
///
/// [`create_dir_all`]: super::create_dir_all()
///
/// # Examples
///
/// ```no_run
/// use tokio::fs;
/// use std::io;
///
/// #[tokio::main]
/// async fn main() -> io::Result<()> {
///     fs::create_dir("/some/dir").await?;
///     Ok(())
/// }
/// ```
pub async fn create_dir(path: impl AsRef<Path>) -> io::Result<()> {
    let path = path.as_ref().to_owned();
    asyncify(move || std::fs::create_dir(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.rs
wasmtime-14.0.3 ./ext/cargo-vendor/tokio-1.33.0/src/fs/create_dir.rs
wasmtime-14.0.1 ./ext/cargo-vendor/tokio-1.33.0/src/fs/create_dir.rs
wasmtime-14.0.0 ./ext/cargo-vendor/tokio-1.33.0/src/fs/create_dir.rs
wasmtime-13.0.0 ./ext/cargo-vendor/tokio-1.32.0/src/fs/create_dir.rs
wasmtime-12.0.1 ./ext/cargo-vendor/tokio-1.32.0/src/fs/create_dir.rs
wasmtime-12.0.0 ./ext/cargo-vendor/tokio-1.32.0/src/fs/create_dir.rs
wasmtime-11.0.0 ./ext/cargo-vendor/tokio-1.32.0/src/fs/create_dir.rs
wasmtime-10.0.1 ./ext/cargo-vendor/tokio-1.30.0/src/fs/create_dir.rs
wasmtime-10.0.0 ./ext/cargo-vendor/tokio-1.30.0/src/fs/create_dir.rs
wasmtime-9.0.4 ./ext/cargo-vendor/tokio-1.30.0/src/fs/create_dir.rs
wasmtime-9.0.1 ./ext/cargo-vendor/tokio-1.28.1/src/fs/create_dir.rs
wasmtime-8.0.0 ./ext/cargo-vendor/tokio-1.27.0/src/fs/create_dir.rs
wasmtime-7.0.0 ./ext/cargo-vendor/tokio-1.27.0/src/fs/create_dir.rs
wasmtime-6.0.1 ./ext/cargo-vendor/tokio-1.25.0/src/fs/create_dir.rs
wasmtime-6.0.0 ./ext/cargo-vendor/tokio-1.25.0/src/fs/create_dir.rs
wasmtime-5.0.0 ./ext/cargo-vendor/tokio-1.24.2/src/fs/create_dir.rs
wasmtime-0.4.1 ./ext/cargo-vendor/tokio-1.23.0/src/fs/create_dir.rs
wasmtime-0.4.0 ./ext/cargo-vendor/tokio-1.23.0/src/fs/create_dir.rs