Skip to main content

polars_io/utils/
mkdir.rs

1use std::io;
2
3use polars_utils::pl_path::PlRefPath;
4
5pub fn mkdir_recursive(path: &PlRefPath) -> io::Result<()> {
6    if !path.has_scheme() {
7        std::fs::DirBuilder::new().recursive(true).create(
8            path.parent()
9                .ok_or(io::Error::other("path is not a file"))?,
10        )?;
11    }
12
13    Ok(())
14}
15
16pub async fn tokio_mkdir_recursive(path: &PlRefPath) -> io::Result<()> {
17    if !path.has_scheme() {
18        tokio::fs::DirBuilder::new()
19            .recursive(true)
20            .create(
21                path.parent()
22                    .ok_or(io::Error::other("path is not a file"))?,
23            )
24            .await?;
25    }
26
27    Ok(())
28}