Work on instance loading a little bit

This commit is contained in:
Lucien Greathouse 2018-04-12 23:49:58 -07:00
parent e9bc66e5e3
commit d0f821add4
5 changed files with 158 additions and 43 deletions

View file

@ -1,5 +1,7 @@
use std::path::{Path, PathBuf};
use partition::Partition;
// TODO: Add lifetime, switch to using Cow<'a, str> instead of String? It's
// possible that it would be too cumbersome!
#[derive(Debug, Clone, PartialEq, Hash)]
@ -34,4 +36,21 @@ impl FileRoute {
result
}
/// This function is totally wrong and should be handled by middleware, heh.
pub fn name(&self, partition: &Partition) -> String { // I guess??
if self.route.len() == 0 {
// This FileRoute refers to the partition itself
if partition.target.len() == 0 {
// We're targeting the game itself!
"game".to_string()
} else {
partition.target.last().unwrap().clone()
}
} else {
// This FileRoute refers to an item in a partition
self.route.last().unwrap().clone()
}
}
}