pub fn fd_seek(&mut self, fd: usize, offset: isize, seek: Whence) -> Result<usize> {
        match seek {
            Whence::Set => {
                self.file_descriptors
                    .get_mut(&fd)
                    .ok_or("Could not find fd for fd_seek")?
                    .set_offset(offset as usize);
            }
            Whence::Cursor => {
                let fd = self
                    .file_descriptors
                    .get_mut(&fd)
                    .ok_or("Could not find fd for fd_seek")?;

                let cur_offset = fd.offset();
                fd.set_offset((cur_offset as isize + offset) as usize);
            }
            Whence::End => {
                let path = self
                    .file_descriptors
                    .get(&fd)
                    .ok_or("Could not find fd for fd_seek")?
                    .path()
                    .to_string(); // kill the borrow
                let filesize = self
                    .files
                    .get(&path)
                    .ok_or("Could not find file for fd_seek SEEK_END")?
                    .len();
                self.file_descriptors
                    .get_mut(&fd)
                    .ok_or("Could not find fd for fd_seek")?
                    .set_offset((filesize as isize + offset) as usize);
            }
        }

        Ok(self
            .file_descriptors
            .get(&fd)
            .ok_or("Could not find fd for fd_seek")?
            .offset())
    }
/// Seek a file descriptor, according to the whence and offset.
Seek a file descriptor, according to the whence and offset.
Seek a file descriptor according to the whence and offset .
pub fn fd_seek(&mut self, fd: usize, offset: isize, seek: Whence) -> Result<usize> {
        match seek {
            Whence::Set => {
                self.file_descriptors
                    .get_mut(&fd)
                    .ok_or("Could not find fd for fd_seek")?
                    .set_offset(offset as usize);
            }
            Whence::Cursor => {
                let fd = self
                    .file_descriptors
                    .get_mut(&fd)
                    .ok_or("Could not find fd for fd_seek")?;
                let cur_offset = fd.offset();
                fd.set_offset((cur_offset as isize + offset) as usize);
            }
            Whence::End => {
                let path = self
                    .file_descriptors
                    .get(&fd)
                    .ok_or("Could not find fd for fd_seek")?
                    .path()
                    .to_string(); // kill the borrow
                let filesize = self
                    .files
                    .get(&path)
                    .ok_or("Could not find file for fd_seek SEEK_END")?
                    .len();
                self.file_descriptors
                    .get_mut(&fd)
                    .ok_or("Could not find fd for fd_seek")?
                    .set_offset((filesize as isize + offset) as usize);
            }
        }
        Ok(self
            .file_descriptors
            .get(&fd)
            .ok_or("Could not find fd for fd_seek")?
            .offset())
    }
pub fn fd_seek ( & mut self , fd : usize , offset : isize , seek : Whence ) -> Result < usize > { match seek { Whence :: Set => { self . file_descriptors . get_mut ( & fd ) . ok_or ( " " ) ? . set_offset ( offset as usize ) ; } Whence :: Cursor => { let fd = self . file_descriptors . get_mut ( & fd ) . ok_or ( " " ) ? ; let cur_offset = fd . offset ( ) ; fd . set_offset ( ( cur_offset as isize + offset ) as usize ) ; } Whence :: End => { let path = self . file_descriptors . get ( & fd ) . ok_or ( " " ) ? . path ( ) . to_string ( ) ; // kill the borrow let filesize = self . files . get ( & path ) . ok_or ( " " ) ? . len ( ) ; self . file_descriptors . get_mut ( & fd ) . ok_or ( " " ) ? . set_offset ( ( filesize as isize + offset ) as usize ) ; } } Ok ( self . file_descriptors . get ( & fd ) . ok_or ( " " ) ? . offset ( ) ) }
Seek a file descriptor, according to the whence and offset.
Seek a file descriptor according to the whence and offset .
&mut self
fd
usize
offset
isize
seek
Whence