Forgot to commit the main code file change with the last commit.

This commit is contained in:
Jason Travis Smith 2016-04-28 01:46:35 -04:00
parent 4fd0d65e07
commit 931ea0c4aa

View File

@ -17,6 +17,9 @@ const DEFAULT_MANIFEST_FILENAME: &'static str = "resources.msnr";
/// The default name to be used for the resource manifest file. /// The default name to be used for the resource manifest file.
const DEFAULT_LOADER_FILENAME: &'static str = "resources.msnl"; 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. /// Defines a resource to be compiled.
@ -78,7 +81,7 @@ impl Section
type_hint: String::new(), type_hint: String::new(),
src_path: String::new(), src_path: String::new(),
dst_path: String::new(), dst_path: String::new(),
compiler: String::new(), compiler: String::from(DEFAULT_COMPILER),
arguments: String::new() arguments: String::new()
} }
} }
@ -311,11 +314,35 @@ impl Processor
} }
/// Compile all the resources in the Section list. /// 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_path: &Path;
let mut dst_dir: PathBuf; 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() for section in self.sections.iter()
{ {
// Get a copy of the output directory // Get a copy of the output directory
@ -380,10 +407,16 @@ impl Processor
fn run_copier(&self, section: &Section, _args: &Vec<String>) fn run_copier(&self, section: &Section, _args: &Vec<String>)
{ {
let src: PathBuf;
let dst: PathBuf;
if section.src_path != section.dst_path if section.src_path != section.dst_path
{ {
match ::std::fs::copy(Path::new(&section.src_path), src = PathBuf::from(section.src_path.clone());
Path::new(&section.dst_path)) dst = PathBuf::from(section.dst_path.clone());
println!("Src: {:?}\nDst: {:?}", src, dst);
match ::std::fs::copy(src, dst)
{ {
Ok(bytes) => Ok(bytes) =>
{ {