pub fn core_readdir(&mut self, chunk: &Chunk, i: usize) -> i32 {
        if self.stack.len() < 1 {
            print_error(chunk, i, "readdir requires one argument");
            return 0;
        }

        let dir_handle_rr = self.stack.pop().unwrap();
        let mut dir_handle_rrb = dir_handle_rr.borrow_mut();

        let entry_value = match *dir_handle_rrb {
            Value::DirectoryHandle(ref mut dir_handle) => {
                let entry_opt = dir_handle.next();
                match entry_opt {
                    Some(s) => {
                        let path = s.unwrap().path();
                        Rc::new(RefCell::new(Value::String(
                            path.to_str().unwrap().to_string(),
                            None,
                        )))
                    }
                    None => Rc::new(RefCell::new(Value::Null)),
                }
            }
            _ => {
                print_error(
                    chunk,
                    i,
                    "readdir argument must be a directory handle",
                );
                return 0;
            }
        };

        self.stack.push(entry_value);
        return 1;
    }
/// Takes a DirectoryHandle object as its single argument.  Reads
/// the next entry from the corresponding handle and places it
/// onto the stack.
Takes a DirectoryHandle object as its single argument.  Reads
the next entry from the corresponding handle and places it
onto the stack.
Takes a DirectoryHandle object as its single argument . Reads the next entry from the corresponding handle and places it onto the stack .
pub fn core_readdir(&mut self, chunk: &Chunk, i: usize) -> i32 {
        if self.stack.len() < 1 {
            print_error(chunk, i, "readdir requires one argument");
            return 0;
        }
        let dir_handle_rr = self.stack.pop().unwrap();
        let mut dir_handle_rrb = dir_handle_rr.borrow_mut();
        let entry_value = match *dir_handle_rrb {
            Value::DirectoryHandle(ref mut dir_handle) => {
                let entry_opt = dir_handle.next();
                match entry_opt {
                    Some(s) => {
                        let path = s.unwrap().path();
                        Rc::new(RefCell::new(Value::String(
                            path.to_str().unwrap().to_string(),
                            None,
                        )))
                    }
                    None => Rc::new(RefCell::new(Value::Null)),
                }
            }
            _ => {
                print_error(
                    chunk,
                    i,
                    "readdir argument must be a directory handle",
                );
                return 0;
            }
        };
        self.stack.push(entry_value);
        return 1;
    }
pub fn core_readdir ( & mut self , chunk : & Chunk , i : usize ) -> i32 { if self . stack . len ( ) < 1 { print_error ( chunk , i , " " ) ; return 0 ; } let dir_handle_rr = self . stack . pop ( ) . unwrap ( ) ; let mut dir_handle_rrb = dir_handle_rr . borrow_mut ( ) ; let entry_value = match * dir_handle_rrb { Value :: DirectoryHandle ( ref mut dir_handle ) => { let entry_opt = dir_handle . next ( ) ; match entry_opt { Some ( s ) => { let path = s . unwrap ( ) . path ( ) ; Rc :: new ( RefCell :: new ( Value :: String ( path . to_str ( ) . unwrap ( ) . to_string ( ) , None , ) ) ) } None => Rc :: new ( RefCell :: new ( Value :: Null ) ) , } } _ => { print_error ( chunk , i , " " , ) ; return 0 ; } } ; self . stack . push ( entry_value ) ; return 1 ; }
Takes a DirectoryHandle object as its single argument.
Takes a DirectoryHandle object as its single argument .
&mut self
chunk
&Chunk
i
usize