pub fn open(&mut self, path: &str) -> Result<Option<usize>> {
        if self.files.get(path).is_some() {
            return Ok(Some(self.add_file_descriptor(path)));
        }

        if self.get_path(path).exists() {
            let mut file = File::open(&self.get_path(path))?;

            let mut buf = Vec::new();
            file.read_to_end(&mut buf)?;

            let bytes = buf
                .into_iter()
                .map(|byte| il::expr_const(byte as u64, 8))
                .collect::<Vec<il::Expression>>();

            self.files.insert(path.to_string(), RC::new(bytes));
            Ok(Some(self.add_file_descriptor(path)))
        } else {
            Ok(None)
        }
    }
/// Attempt to open a file and read it into the filesystem model. Returns
/// a file descriptor if the file exists, or None.
Attempt to open a file and read it into the filesystem model. Returns
a file descriptor if the file exists, or None.
Attempt to open a file and read it into the filesystem model . Returns a file descriptor if the file exists or None .
pub fn open(&mut self, path: &str) -> Result<Option<usize>> {
        if self.files.get(path).is_some() {
            return Ok(Some(self.add_file_descriptor(path)));
        }
        if self.get_path(path).exists() {
            let mut file = File::open(&self.get_path(path))?;
            let mut buf = Vec::new();
            file.read_to_end(&mut buf)?;
            let bytes = buf
                .into_iter()
                .map(|byte| il::expr_const(byte as u64, 8))
                .collect::<Vec<il::Expression>>();
            self.files.insert(path.to_string(), RC::new(bytes));
            Ok(Some(self.add_file_descriptor(path)))
        } else {
            Ok(None)
        }
    }
pub fn open ( & mut self , path : & str ) -> Result < Option < usize > > { if self . files . get ( path ) . is_some ( ) { return Ok ( Some ( self . add_file_descriptor ( path ) ) ) ; } if self . get_path ( path ) . exists ( ) { let mut file = File :: open ( & self . get_path ( path ) ) ? ; let mut buf = Vec :: new ( ) ; file . read_to_end ( & mut buf ) ? ; let bytes = buf . into_iter ( ) . map ( | byte | il :: expr_const ( byte as u64 , 8 ) ) . collect :: < Vec < il :: Expression > > ( ) ; self . files . insert ( path . to_string ( ) , RC :: new ( bytes ) ) ; Ok ( Some ( self . add_file_descriptor ( path ) ) ) } else { Ok ( None ) } }
Attempt to open a file and read it into the filesystem model.
Attempt to open a file and read it into the filesystem model .
&mut self
path
&str