mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-04-21 13:15:50 +00:00
Imfs test
This commit is contained in:
@@ -77,7 +77,8 @@ pub fn build(options: &BuildOptions) -> Result<(), BuildError> {
|
||||
info!("Found project at {}", project.file_location.display());
|
||||
info!("Using project {:#?}", project);
|
||||
|
||||
let imfs = Imfs::new(&project)?;
|
||||
let mut imfs = Imfs::new();
|
||||
imfs.add_roots_from_project(&project)?;
|
||||
let tree = construct_oneoff_tree(&project, &imfs);
|
||||
let mut file = File::create(&options.output_file)?;
|
||||
|
||||
|
||||
@@ -32,25 +32,25 @@ pub struct Imfs {
|
||||
}
|
||||
|
||||
impl Imfs {
|
||||
pub fn new(project: &Project) -> io::Result<Imfs> {
|
||||
let mut imfs = Imfs::empty();
|
||||
|
||||
add_sync_points(&mut imfs, &project.tree)?;
|
||||
|
||||
Ok(imfs)
|
||||
}
|
||||
|
||||
pub fn empty() -> Imfs {
|
||||
pub fn new() -> Imfs {
|
||||
Imfs {
|
||||
items: HashMap::new(),
|
||||
roots: HashSet::new(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn add_roots_from_project(&mut self, project: &Project) -> io::Result<()> {
|
||||
add_sync_points(self, &project.tree)
|
||||
}
|
||||
|
||||
pub fn get_roots(&self) -> &HashSet<PathBuf> {
|
||||
&self.roots
|
||||
}
|
||||
|
||||
pub fn get_items(&self) -> &HashMap<PathBuf, ImfsItem> {
|
||||
&self.items
|
||||
}
|
||||
|
||||
pub fn get(&self, path: &Path) -> Option<&ImfsItem> {
|
||||
debug_assert!(path.is_absolute());
|
||||
debug_assert!(self.is_within_roots(path));
|
||||
@@ -141,19 +141,19 @@ impl Imfs {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub struct ImfsFile {
|
||||
pub path: PathBuf,
|
||||
pub contents: Vec<u8>,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub struct ImfsDirectory {
|
||||
pub path: PathBuf,
|
||||
pub children: HashSet<PathBuf>,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub enum ImfsItem {
|
||||
File(ImfsFile),
|
||||
Directory(ImfsDirectory),
|
||||
|
||||
@@ -22,7 +22,12 @@ pub struct Session {
|
||||
|
||||
impl Session {
|
||||
pub fn new(project: Project) -> io::Result<Session> {
|
||||
let imfs = Arc::new(Mutex::new(Imfs::new(&project)?));
|
||||
let imfs = {
|
||||
let mut imfs = Imfs::new();
|
||||
imfs.add_roots_from_project(&project)?;
|
||||
|
||||
Arc::new(Mutex::new(imfs))
|
||||
};
|
||||
let project = Arc::new(project);
|
||||
let message_queue = Arc::new(MessageQueue::new());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user