polars_io/utils/
mkdir.rs
1use std::io;
2use std::path::Path;
3
4pub fn mkdir_recursive(path: &Path) -> io::Result<()> {
5 std::fs::DirBuilder::new().recursive(true).create(
6 path.parent()
7 .ok_or(io::Error::other("path is not a file"))?,
8 )
9}
10
11#[cfg(feature = "tokio")]
12pub async fn tokio_mkdir_recursive(path: &Path) -> io::Result<()> {
13 tokio::fs::DirBuilder::new()
14 .recursive(true)
15 .create(
16 path.parent()
17 .ok_or(io::Error::other("path is not a file"))?,
18 )
19 .await
20}