This commit is contained in:
Adrian Heine 2017-05-10 14:21:51 +02:00
parent a4ae7531a3
commit 73b2184d24
8 changed files with 108 additions and 36 deletions

View file

@ -2,7 +2,9 @@ use std::error::Error;
use std::fmt;
use std::fs;
use std::io;
use std::path::Path;
use resources::Resource;
use symbols::Symbol;
pub struct Dir<D> where D: AsRef<str> + fmt::Display {
@ -34,7 +36,19 @@ impl<D> Symbol for Dir<D> where D: AsRef<str> + fmt::Display {
}
fn execute(&self) -> Result<(), Box<Error>> {
fs::create_dir_all(self.path.as_ref()).map_err(|e| Box::new(e) as Box<Error>)
fs::create_dir(self.path.as_ref()).map_err(|e| Box::new(e) as Box<Error>)
}
fn get_prerequisites(&self) -> Vec<Resource> {
if let Some(parent) = Path::new(self.path.as_ref()).parent() {
vec![ Resource::new("dir", parent.to_string_lossy()) ]
} else {
vec![]
}
}
fn provides(&self) -> Option<Vec<Resource>> {
Some(vec![ Resource::new("dir", self.path.to_string()) ])
}
}