Keep track of actual file name in VfsItem.

This should fix the case of a partition pointed directly at a file
turning the object into a `StringValue`.

Fixes #57.
This commit is contained in:
Lucien Greathouse
2018-04-20 23:13:43 -07:00
parent 9e956e593d
commit 187194a615
3 changed files with 13 additions and 1 deletions

View File

@@ -9,17 +9,22 @@ use std::collections::HashMap;
pub enum VfsItem {
File {
route: Vec<String>,
file_name: String,
contents: String,
},
Dir {
route: Vec<String>,
file_name: String,
children: HashMap<String, VfsItem>,
},
}
impl VfsItem {
pub fn name(&self) -> &String {
self.route().last().unwrap()
match self {
&VfsItem::File { ref file_name , .. } => file_name,
&VfsItem::Dir { ref file_name , .. } => file_name,
}
}
pub fn route(&self) -> &[String] {