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

        let path_rr = self.stack.pop().unwrap();
        let path_rrb = path_rr.borrow();
        let path_str_pre = path_rrb.to_string();
        let path_str_opt = to_string_2(&path_str_pre);

        match path_str_opt {
            Some(s) => {
                let dir_handle_res = std::fs::read_dir(s);
                match dir_handle_res {
                    Ok(dir_handle) => {
                        self.stack.push(
                            Rc::new(RefCell::new(Value::DirectoryHandle(dir_handle))));
                        return 1;
                    }
                    Err(e) => {
                        let err_str = format!(
                            "unable to open directory: {}",
                            e.to_string()
                        );
                        print_error(chunk, i, &err_str);
                        return 0;
                    }
                }
            }
            _ => {
                print_error(chunk, i, "opendir argument must be a string");
                return 0;
            }
        }
    }
/// Takes a directory path as its single argument.  Opens the
/// directory and places a DirectoryHandle object for the
/// directory onto the stack.
Takes a directory path as its single argument.  Opens the
directory and places a DirectoryHandle object for the
directory onto the stack.
Takes a directory path as its single argument . Opens the directory and places a DirectoryHandle object for the directory onto the stack .
pub fn core_opendir(&mut self, chunk: &Chunk, i: usize) -> i32 {
        if self.stack.len() < 1 {
            print_error(chunk, i, "opendir requires one argument");
            return 0;
        }
        let path_rr = self.stack.pop().unwrap();
        let path_rrb = path_rr.borrow();
        let path_str_pre = path_rrb.to_string();
        let path_str_opt = to_string_2(&path_str_pre);
        match path_str_opt {
            Some(s) => {
                let dir_handle_res = std::fs::read_dir(s);
                match dir_handle_res {
                    Ok(dir_handle) => {
                        self.stack.push(
                            Rc::new(RefCell::new(Value::DirectoryHandle(dir_handle))));
                        return 1;
                    }
                    Err(e) => {
                        let err_str = format!(
                            "unable to open directory: {}",
                            e.to_string()
                        );
                        print_error(chunk, i, &err_str);
                        return 0;
                    }
                }
            }
            _ => {
                print_error(chunk, i, "opendir argument must be a string");
                return 0;
            }
        }
    }
pub fn core_opendir ( & mut self , chunk : & Chunk , i : usize ) -> i32 { if self . stack . len ( ) < 1 { print_error ( chunk , i , " " ) ; return 0 ; } let path_rr = self . stack . pop ( ) . unwrap ( ) ; let path_rrb = path_rr . borrow ( ) ; let path_str_pre = path_rrb . to_string ( ) ; let path_str_opt = to_string_2 ( & path_str_pre ) ; match path_str_opt { Some ( s ) => { let dir_handle_res = std :: fs :: read_dir ( s ) ; match dir_handle_res { Ok ( dir_handle ) => { self . stack . push ( Rc :: new ( RefCell :: new ( Value :: DirectoryHandle ( dir_handle ) ) ) ) ; return 1 ; } Err ( e ) => { let err_str = format ! ( " " e to_string ( ) ) ; print_error ( chunk , i , & err_str ) ; return 0 ; } } } _ => { print_error ( chunk , i , " " ) ; return 0 ; } } }
Takes a directory path as its single argument.
Takes a directory path as its single argument .
&mut self
chunk
&Chunk
i
usize