rustfilesystemsmkdir

Rust equivalent of mkdir -p


What's the Rust equivalent of mkdir -p <dir>? The -p flag tells mkdir to create any missing parent directories as needed, and also not to error if <dir> already exists.

Is there any easy way to do this with the Rust standard library?


Solution

  • That is create_dir_all.

    std::fs::create_dir_all(dir_path)