tokio_fs/
create_dir_all.rs1use std::fs;
2use std::io;
3use std::path::Path;
4
5use futures::{Future, Poll};
6
7pub fn create_dir_all<P: AsRef<Path>>(path: P) -> CreateDirAllFuture<P> {
14 CreateDirAllFuture::new(path)
15}
16
17#[derive(Debug)]
19pub struct CreateDirAllFuture<P>
20where
21 P: AsRef<Path>,
22{
23 path: P,
24}
25
26impl<P> CreateDirAllFuture<P>
27where
28 P: AsRef<Path>,
29{
30 fn new(path: P) -> CreateDirAllFuture<P> {
31 CreateDirAllFuture { path: path }
32 }
33}
34
35impl<P> Future for CreateDirAllFuture<P>
36where
37 P: AsRef<Path>,
38{
39 type Item = ();
40 type Error = io::Error;
41
42 fn poll(&mut self) -> Poll<Self::Item, Self::Error> {
43 ::blocking_io(|| fs::create_dir_all(&self.path))
44 }
45}