Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
pola-rs
GitHub Repository: pola-rs/polars
Path: blob/main/crates/polars-io/src/utils/mkdir.rs
8422 views
1
use std::io;
2
3
use polars_utils::pl_path::PlRefPath;
4
5
pub 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
16
#[cfg(feature = "tokio")]
17
pub async fn tokio_mkdir_recursive(path: &PlRefPath) -> io::Result<()> {
18
if !path.has_scheme() {
19
tokio::fs::DirBuilder::new()
20
.recursive(true)
21
.create(
22
path.parent()
23
.ok_or(io::Error::other("path is not a file"))?,
24
)
25
.await?;
26
}
27
28
Ok(())
29
}
30
31