pub fn write_file(&mut self, path: &Path, buf: Cow<'static, [u8]>) -> io::Result<()> {
        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 writable");
            return Err(io::Error::new(io::ErrorKind::PermissionDenied, message));
        }
        let path = normalize_slashes(path).map_err(|err| io::Error::new(io::ErrorKind::NotFound, err))?;
        match self.fs.entry(path.into()) {
            HashEntry::Occupied(mut entry) => {
                entry.get_mut().replace_content(buf);
            }
            HashEntry::Vacant(entry) => {
                entry.insert(Entry::from(buf));
            }
        }
        Ok(())
    }
/// Write file contents into the virtual file system at `path`.
///
/// Writes the full file contents. If any file contents already exist at
/// `path`, they are replaced. Extension hooks are preserved.
///
/// # Errors
///
/// This API is currently infallible but returns [`io::Result`] to reserve
/// the ability to return errors in the future.
Write file contents into the virtual file system at `path`.
Writes the full file contents. If any file contents already exist at
`path`, they are replaced. Extension hooks are preserved.
Write file contents into the virtual file system at ` path ` . Writes the full file contents . If any file contents already exist at ` path ` they are replaced . Extension hooks are preserved .
pub fn write_file(&mut self, path: &Path, buf: Cow<'static, [u8]>) -> io::Result<()> {
        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 writable");
            return Err(io::Error::new(io::ErrorKind::PermissionDenied, message));
        }
        let path = normalize_slashes(path).map_err(|err| io::Error::new(io::ErrorKind::NotFound, err))?;
        match self.fs.entry(path.into()) {
            HashEntry::Occupied(mut entry) => {
                entry.get_mut().replace_content(buf);
            }
            HashEntry::Vacant(entry) => {
                entry.insert(Entry::from(buf));
            }
        }
        Ok(())
    }
pub fn write_file ( & mut self , path : & Path , buf : Cow < ' static , [ u8 ] > ) -> io :: Result < ( ) > { 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 :: PermissionDenied , message ) ) ; } let path = normalize_slashes ( path ) . map_err ( | err | io :: Error :: new ( io :: ErrorKind :: NotFound , err ) ) ? ; match self . fs . entry ( path . into ( ) ) { HashEntry :: Occupied ( mut entry ) => { entry . get_mut ( ) . replace_content ( buf ) ; } HashEntry :: Vacant ( entry ) => { entry . insert ( Entry :: from ( buf ) ) ; } } Ok ( ( ) ) }
Write file contents into the virtual file system at `path`.
Write file contents into the virtual file system at ` path ` .
&mut self
path
&Path
buf
Cow<'static, [u8]>
errors
This API is currently infallible but returns [`io::Result`] to reserve
the ability to return errors in the future.
This API is currently infallible but returns [ ` io :: Result ` ] to reserve the ability to return errors in the future .