pub fn core_is_dir(&mut self, chunk: &Chunk, i: usize) -> i32 {
        if self.stack.len() < 1 {
            print_error(chunk, i, "is-dir 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 metadata_res = metadata(s);
                match metadata_res {
                    Ok(metadata) => {
                        let is_dir = match metadata.is_dir() {
                            true => 1,
                            false => 0,
                        };
                        self.stack
                            .push(Rc::new(RefCell::new(Value::Int(is_dir))));
                    }
                    _ => {
                        self.stack.push(Rc::new(RefCell::new(Value::Int(0))));
                    }
                }
            }
            _ => {
                print_error(chunk, i, "is-dir argument must be a string");
                return 0;
            }
        }
        return 1;
    }
/// Takes a path as its single argument.  Places a boolean onto
/// the stack indicating whether the path maps to a directory.
Takes a path as its single argument.  Places a boolean onto
the stack indicating whether the path maps to a directory.
Takes a path as its single argument . Places a boolean onto the stack indicating whether the path maps to a directory .
pub fn core_is_dir(&mut self, chunk: &Chunk, i: usize) -> i32 {
        if self.stack.len() < 1 {
            print_error(chunk, i, "is-dir 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 metadata_res = metadata(s);
                match metadata_res {
                    Ok(metadata) => {
                        let is_dir = match metadata.is_dir() {
                            true => 1,
                            false => 0,
                        };
                        self.stack
                            .push(Rc::new(RefCell::new(Value::Int(is_dir))));
                    }
                    _ => {
                        self.stack.push(Rc::new(RefCell::new(Value::Int(0))));
                    }
                }
            }
            _ => {
                print_error(chunk, i, "is-dir argument must be a string");
                return 0;
            }
        }
        return 1;
    }
pub fn core_is_dir ( & 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 metadata_res = metadata ( s ) ; match metadata_res { Ok ( metadata ) => { let is_dir = match metadata . is_dir ( ) { true => 1 , false => 0 , } ; self . stack . push ( Rc :: new ( RefCell :: new ( Value :: Int ( is_dir ) ) ) ) ; } _ => { self . stack . push ( Rc :: new ( RefCell :: new ( Value :: Int ( 0 ) ) ) ) ; } } } _ => { print_error ( chunk , i , " " ) ; return 0 ; } } return 1 ; }
Takes a path as its single argument.
Takes a path as its single argument .
&mut self
chunk
&Chunk
i
usize