Expose mount on Collection
This commit is contained in:
parent
96d12c7517
commit
842514da85
3 changed files with 8 additions and 5 deletions
|
@ -30,9 +30,11 @@ impl Collection {
|
||||||
vfs: Vfs::new(),
|
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> {
|
pub fn browse(&self, path: &Path) -> Result<Vec<CollectionFile>, CollectionError> {
|
||||||
|
|
||||||
let full_path = try!(self.vfs.virtual_to_real(path));
|
let full_path = try!(self.vfs.virtual_to_real(path));
|
||||||
|
|
|
@ -5,6 +5,7 @@ extern crate rustc_serialize;
|
||||||
extern crate staticfile;
|
extern crate staticfile;
|
||||||
extern crate url;
|
extern crate url;
|
||||||
|
|
||||||
|
use std::path::Path;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use std::sync::Mutex;
|
use std::sync::Mutex;
|
||||||
|
|
||||||
|
@ -22,7 +23,8 @@ use collection::*;
|
||||||
|
|
||||||
fn main() {
|
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 collection = Arc::new(Mutex::new(collection));
|
||||||
|
|
||||||
let mut mount = Mount::new();
|
let mut mount = Mount::new();
|
||||||
|
|
|
@ -16,8 +16,7 @@ impl Vfs {
|
||||||
instance
|
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();
|
let name = name.to_string();
|
||||||
if self.mount_points.contains_key(&name) {
|
if self.mount_points.contains_key(&name) {
|
||||||
return Err(CollectionError::ConflictingMount);
|
return Err(CollectionError::ConflictingMount);
|
||||||
|
|
Loading…
Add table
Reference in a new issue