Expose mount on Collection

This commit is contained in:
Antoine Gersant 2016-08-21 21:40:33 -07:00
parent 96d12c7517
commit 842514da85
3 changed files with 8 additions and 5 deletions

View file

@ -30,9 +30,11 @@ impl Collection {
vfs: Vfs::new(),
}
}
}
impl Collection {
pub fn mount(&mut self, name: &str, real_path: &Path) -> Result<(), CollectionError> {
self.vfs.mount(name, real_path)
}
pub fn browse(&self, path: &Path) -> Result<Vec<CollectionFile>, CollectionError> {
let full_path = try!(self.vfs.virtual_to_real(path));

View file

@ -5,6 +5,7 @@ extern crate rustc_serialize;
extern crate staticfile;
extern crate url;
use std::path::Path;
use std::sync::Arc;
use std::sync::Mutex;
@ -22,7 +23,8 @@ use collection::*;
fn main() {
let collection = Collection::new();
let mut collection = Collection::new();
collection.mount("root", Path::new("samplemusic/"));
let collection = Arc::new(Mutex::new(collection));
let mut mount = Mount::new();

View file

@ -16,8 +16,7 @@ impl Vfs {
instance
}
pub fn mount(&mut self, name: &str, real_path: &Path) -> Result<(), CollectionError>
{
pub fn mount(&mut self, name: &str, real_path: &Path) -> Result<(), CollectionError> {
let name = name.to_string();
if self.mount_points.contains_key(&name) {
return Err(CollectionError::ConflictingMount);