fn load_children(&self, parent: &mut Node) -> Result<Vec<Tree>> {
        let mut result = Vec::new();

        if !parent.is_dir() {
            return Ok(result);
        }

        let children = fs::read_dir(&parent.path)?;
        let children = children.collect::<Result<Vec<DirEntry>>>()?;

        for child in children {
            let path = child.path();

            let child = Node::new(
                self.root_path.clone(),
                path.clone(),
                Overlay::UpperAddition,
                parent.explicit_uidgid,
            )?;

            // Per as to OCI spec, whiteout file should not be present within final image
            // or filesystem, only existed in layers.
            if child.whiteout_type().is_some() && !self.layered {
                continue;
            }

            // Ignore special file
            if child.file_type() == "" {
                continue;
            }

            let mut child_tree = Tree::new(child);
            child_tree.children = self.load_children(&mut child_tree.node)?;
            result.push(child_tree);
        }

        Ok(result)
    }
/// Walk directory to build node tree by DFS,
Walk directory to build node tree by DFS.
Walk directory to build node tree by DFS .
fn load_children(&self, parent: &mut Node) -> Result<Vec<Tree>> {
        let mut result = Vec::new();
        if !parent.is_dir() {
            return Ok(result);
        }
        let children = fs::read_dir(&parent.path)?;
        let children = children.collect::<Result<Vec<DirEntry>>>()?;
        for child in children {
            let path = child.path();
            let child = Node::new(
                self.root_path.clone(),
                path.clone(),
                Overlay::UpperAddition,
                parent.explicit_uidgid,
            )?;
            // Per as to OCI spec, whiteout file should not be present within final image
            // or filesystem, only existed in layers.
            if child.whiteout_type().is_some() && !self.layered {
                continue;
            }
            // Ignore special file
            if child.file_type() == "" {
                continue;
            }
            let mut child_tree = Tree::new(child);
            child_tree.children = self.load_children(&mut child_tree.node)?;
            result.push(child_tree);
        }
        Ok(result)
    }
fn load_children ( & self , parent : & mut Node ) -> Result < Vec < Tree > > { let mut result = Vec :: new ( ) ; if ! parent . is_dir ( ) { return Ok ( result ) ; } let children = fs :: read_dir ( & parent . path ) ? ; let children = children . collect :: < Result < Vec < DirEntry > > > ( ) ? ; for child in children { let path = child . path ( ) ; let child = Node :: new ( self . root_path . clone ( ) , path . clone ( ) , Overlay :: UpperAddition , parent . explicit_uidgid , ) ? ; // Per as to OCI spec, whiteout file should not be present within final image // or filesystem, only existed in layers. if child . whiteout_type ( ) . is_some ( ) && ! self . layered { continue ; } // Ignore special file if child . file_type ( ) == " " { continue ; } let mut child_tree = Tree :: new ( child ) ; child_tree . children = self . load_children ( & mut child_tree . node ) ? ; result . push ( child_tree ) ; } Ok ( result ) }
Walk directory to build node tree by DFS,
Walk directory to build node tree by DFS
&self
parent
&mut Node
&self
parent
&mut Node