diff --git a/src/processor.rs b/src/processor.rs index 4abd38c..9db65f8 100644 --- a/src/processor.rs +++ b/src/processor.rs @@ -17,6 +17,9 @@ const DEFAULT_MANIFEST_FILENAME: &'static str = "resources.msnr"; /// The default name to be used for the resource manifest file. const DEFAULT_LOADER_FILENAME: &'static str = "resources.msnl"; +/// The default compiler is the copy compiler. +const DEFAULT_COMPILER: &'static str = "copy"; + /// Defines a resource to be compiled. @@ -78,7 +81,7 @@ impl Section type_hint: String::new(), src_path: String::new(), dst_path: String::new(), - compiler: String::new(), + compiler: String::from(DEFAULT_COMPILER), arguments: String::new() } } @@ -311,11 +314,35 @@ impl Processor } /// Compile all the resources in the Section list. - fn compile_resources(&self) + fn compile_resources(&mut self) { + let mut dir: PathBuf; let mut dst_path: &Path; let mut dst_dir: PathBuf; + // Adjust the src path to be from the resources directory. + for section in self.sections.iter_mut() + { + dir = self.resources_dir.clone(); + dir.push(section.src_path.clone()); + match dir.to_str() + { + Some(src_filename) => + { + section.src_path.clear(); + section.src_path.push_str(src_filename); + } + + None => + { + warn!("{} {}", "There was an issue converting the resource's", + "source filename into a string."); + } + } + } + + // Handle making sure that each directory is present + // in the output directory. for section in self.sections.iter() { // Get a copy of the output directory @@ -380,10 +407,16 @@ impl Processor fn run_copier(&self, section: &Section, _args: &Vec) { + let src: PathBuf; + let dst: PathBuf; + if section.src_path != section.dst_path { - match ::std::fs::copy(Path::new(§ion.src_path), - Path::new(§ion.dst_path)) + src = PathBuf::from(section.src_path.clone()); + dst = PathBuf::from(section.dst_path.clone()); + println!("Src: {:?}\nDst: {:?}", src, dst); + + match ::std::fs::copy(src, dst) { Ok(bytes) => {