pub fn read_file(&self, path: &Path) -> io::Result<Cow<'_, [u8]>> {
        let path = absolutize_relative_to(path, &self.cwd);
        if path.strip_prefix(RUBY_LOAD_PATH).is_err() {
            let mut message = String::from("Only paths beginning with ");
            message.push_str(RUBY_LOAD_PATH);
            message.push_str(" are readable");
            return Err(io::Error::new(io::ErrorKind::NotFound, message));
        }
        let path = normalize_slashes(path).map_err(|err| io::Error::new(io::ErrorKind::NotFound, err))?;
        if let Some(entry) = self.fs.get(path.as_bstr()) {
            if let Some(ref code) = entry.code {
                match code.content {
                    Cow::Borrowed(content) => Ok(content.into()),
                    Cow::Owned(ref content) => Ok(content.clone().into()),
                }
            } else {
                Ok(Code::new().into())
            }
        } else {
            Err(io::Error::new(
                io::ErrorKind::NotFound,
                "file not found in virtual file system",
            ))
        }
    }
/// Read file contents for the file at `path`.
///
/// Returns a byte slice of complete file contents. If `path` is relative,
/// it is absolutized relative to the current working directory of the
/// virtual file system.
///
/// # Errors
///
/// If `path` does not exist, an [`io::Error`] with error kind
/// [`io::ErrorKind::NotFound`] is returned.
Read file contents for the file at `path`.
Returns a byte slice of complete file contents. If `path` is relative,
it is absolutized relative to the current working directory of the
virtual file system.
Read file contents for the file at ` path ` . Returns a byte slice of complete file contents . If ` path ` is relative it is absolutized relative to the current working directory of the virtual file system .
pub fn read_file(&self, path: &Path) -> io::Result<Cow<'_, [u8]>> {
        let path = absolutize_relative_to(path, &self.cwd);
        if path.strip_prefix(RUBY_LOAD_PATH).is_err() {
            let mut message = String::from("Only paths beginning with ");
            message.push_str(RUBY_LOAD_PATH);
            message.push_str(" are readable");
            return Err(io::Error::new(io::ErrorKind::NotFound, message));
        }
        let path = normalize_slashes(path).map_err(|err| io::Error::new(io::ErrorKind::NotFound, err))?;
        if let Some(entry) = self.fs.get(path.as_bstr()) {
            if let Some(ref code) = entry.code {
                match code.content {
                    Cow::Borrowed(content) => Ok(content.into()),
                    Cow::Owned(ref content) => Ok(content.clone().into()),
                }
            } else {
                Ok(Code::new().into())
            }
        } else {
            Err(io::Error::new(
                io::ErrorKind::NotFound,
                "file not found in virtual file system",
            ))
        }
    }
pub fn read_file ( & self , path : & Path ) -> io :: Result < Cow < ' _ , [ u8 ] > > { let path = absolutize_relative_to ( path , & self . cwd ) ; if path . strip_prefix ( RUBY_LOAD_PATH ) . is_err ( ) { let mut message = String :: from ( " " ) ; message . push_str ( RUBY_LOAD_PATH ) ; message . push_str ( " " ) ; return Err ( io :: Error :: new ( io :: ErrorKind :: NotFound , message ) ) ; } let path = normalize_slashes ( path ) . map_err ( | err | io :: Error :: new ( io :: ErrorKind :: NotFound , err ) ) ? ; if let Some ( entry ) = self . fs . get ( path . as_bstr ( ) ) { if let Some ( ref code ) = entry . code { match code . content { Cow :: Borrowed ( content ) => Ok ( content . into ( ) ) , Cow :: Owned ( ref content ) => Ok ( content . clone ( ) . into ( ) ) , } } else { Ok ( Code :: new ( ) . into ( ) ) } } else { Err ( io :: Error :: new ( io :: ErrorKind :: NotFound , " " , ) ) } }
Read file contents for the file at `path`.
Read file contents for the file at ` path ` .
&self
path
&Path
errors
If `path` does not exist, an [`io::Error`] with error kind
[`io::ErrorKind::NotFound`] is returned.
If ` path ` does not exist an [ ` io :: Error ` ] with error kind [ ` io :: ErrorKind :: NotFound ` ] is returned .