mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-10-23 22:11:38 +00:00
Prototype plugin architecture, switch instance-based stuff to that
This commit is contained in:
parent
5bf1f11190
commit
21e9625c36
7 changed files with 99 additions and 88 deletions
|
|
@ -37,8 +37,8 @@ pub struct VfsChange {
|
|||
#[derive(Debug, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase", tag = "type")]
|
||||
pub enum VfsItem {
|
||||
File { contents: String },
|
||||
Dir { children: HashMap<String, VfsItem> },
|
||||
File { name: String, contents: String },
|
||||
Dir { name: String, children: HashMap<String, VfsItem> },
|
||||
}
|
||||
|
||||
impl Vfs {
|
||||
|
|
@ -78,6 +78,7 @@ impl Vfs {
|
|||
}
|
||||
|
||||
fn read_dir<P: AsRef<Path>>(&self, path: P) -> Result<VfsItem, ()> {
|
||||
let path = path.as_ref();
|
||||
let reader = match fs::read_dir(path) {
|
||||
Ok(v) => v,
|
||||
Err(_) => return Err(()),
|
||||
|
|
@ -104,11 +105,13 @@ impl Vfs {
|
|||
}
|
||||
|
||||
Ok(VfsItem::Dir {
|
||||
name: path.file_name().unwrap().to_string_lossy().into_owned(),
|
||||
children,
|
||||
})
|
||||
}
|
||||
|
||||
fn read_file<P: AsRef<Path>>(&self, path: P) -> Result<VfsItem, ()> {
|
||||
let path = path.as_ref();
|
||||
let mut file = match File::open(path) {
|
||||
Ok(v) => v,
|
||||
Err(_) => return Err(()),
|
||||
|
|
@ -122,6 +125,7 @@ impl Vfs {
|
|||
}
|
||||
|
||||
Ok(VfsItem::File {
|
||||
name: path.file_name().unwrap().to_string_lossy().into_owned(),
|
||||
contents,
|
||||
})
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue