Syncing sort of works

This commit is contained in:
Lucien Greathouse
2018-11-16 20:32:39 -08:00
parent fb950cb007
commit 9ad0eabb85
6 changed files with 125 additions and 21 deletions

View File

@@ -33,13 +33,20 @@ impl Vfs {
&self.roots
}
pub fn get(&mut self, path: &Path) -> Option<&VfsItem> {
pub fn get(&self, path: &Path) -> Option<&VfsItem> {
debug_assert!(path.is_absolute());
debug_assert!(self.is_valid_path(path));
self.items.get(path)
}
pub fn get_contents(&self, path: &Path) -> Option<&[u8]> {
debug_assert!(path.is_absolute());
debug_assert!(self.is_valid_path(path));
self.contents.get(path).map(Vec::as_slice)
}
pub fn remove(&mut self, path: &Path) {
debug_assert!(path.is_absolute());
debug_assert!(self.is_valid_path(path));
@@ -82,13 +89,13 @@ impl Vfs {
#[derive(Debug)]
pub struct VfsFile {
path: PathBuf,
pub path: PathBuf,
}
#[derive(Debug)]
pub struct VfsDirectory {
path: PathBuf,
children: HashSet<PathBuf>,
pub path: PathBuf,
pub children: HashSet<PathBuf>,
}
#[derive(Debug)]