pub struct FileNode {
pub name: CompactString,
pub native_name: Option<Box<OsString>>,
pub kind: NodeKind,
pub size: u64,
pub len: u64,
pub blocks: u64,
pub timestamps: Timestamps,
pub inode: Option<InodeInfo>,
pub git_status: Option<GitStatus>,
pub children: Vec<FileNode>,
}Expand description
A single file or directory in the tree.
Debug formatting includes this node’s metadata and direct child count, not descendant contents, so logging a node does not walk the entire tree.
Fields§
§name: CompactStringFile/directory name (not full path).
native_name: Option<Box<OsString>>Exact platform filename when the display name cannot represent it.
kind: NodeKindNode type and associated metadata.
size: u64Size in bytes: disk usage, or apparent length when the scan used
apparent sizes. Directories aggregate their contents and their own
allocation; additional hard links to a counted file contribute zero.
Derived from len and blocks; see FileNode::remeasure.
len: u64Apparent length of this entry itself (st_size), not aggregated.
blocks: u64512-byte blocks allocated to this entry itself (not aggregated).
timestamps: TimestampsFile metadata timestamps.
inode: Option<InodeInfo>Identity of multiply-linked files, for hard-link aware analysis.
git_status: Option<GitStatus>Git status for this file/directory.
children: Vec<FileNode>Children nodes (directories only), sorted by size descending.
Implementations§
Source§impl FileNode
impl FileNode
Sourcepub fn compare_name(&self, other: &Self) -> Ordering
pub fn compare_name(&self, other: &Self) -> Ordering
Compare compatibility labels with exact native identity as a tiebreak.
Sourcepub fn display_name(&self) -> Cow<'_, str>
pub fn display_name(&self) -> Cow<'_, str>
Terminal-safe filename label that preserves visible byte distinctions.
Sourcepub fn file_name(&self) -> &OsStr
pub fn file_name(&self) -> &OsStr
Filename component for filesystem access; name is display text only.
Sourcepub fn set_file_name(&mut self, name: &OsStr)
pub fn set_file_name(&mut self, name: &OsStr)
Preserve an exact component while retaining a Unicode display label.
Sourcepub fn new_file(
name: impl Into<CompactString>,
size: u64,
blocks: u64,
timestamps: Timestamps,
executable: bool,
) -> Self
pub fn new_file( name: impl Into<CompactString>, size: u64, blocks: u64, timestamps: Timestamps, executable: bool, ) -> Self
Create a new file node.
Sourcepub fn new_directory(
name: impl Into<CompactString>,
timestamps: Timestamps,
) -> Self
pub fn new_directory( name: impl Into<CompactString>, timestamps: Timestamps, ) -> Self
Create a new, empty directory node.
Sourcepub fn new_symlink(
name: impl Into<CompactString>,
target: impl Into<Box<str>>,
broken: bool,
timestamps: Timestamps,
) -> Self
pub fn new_symlink( name: impl Into<CompactString>, target: impl Into<Box<str>>, broken: bool, timestamps: Timestamps, ) -> Self
Create a symbolic link node.
Sourcepub fn child_count(&self) -> usize
pub fn child_count(&self) -> usize
Get the number of direct children.
Sourcepub fn file_count(&self) -> u64
pub fn file_count(&self) -> u64
Get file count for directories (includes files, symlinks, and other entries), 1 for files/symlinks/other.
Sourcepub fn sort_children_by_size(&mut self)
pub fn sort_children_by_size(&mut self)
Sort children by size descending, breaking ties by name and native name.
Uses stored sizes without recomputing them. Traversal retains one child iterator per directory depth instead of using recursive calls.
Sourcepub fn update_counts(&mut self)
pub fn update_counts(&mut self)
Update directory file/dir counts with an iterative post-order traversal.
Retains one traversal frame per directory depth. Symlinks and Other entries are counted in the file count; non-directory children are leaves.
Sourcepub fn own_size(&self, apparent: bool) -> u64
pub fn own_size(&self, apparent: bool) -> u64
This entry’s own size under apparent: its length, or its allocated
blocks. Symbolic links count as zero, as in a scan.
Sourcepub fn remeasure(&mut self, apparent: bool, count_hard_links: bool)
pub fn remeasure(&mut self, apparent: bool, count_hard_links: bool)
Recompute every size below and including this node from the entries’
own lengths and blocks, then re-sort children by size.
A multiply linked file (one with an inode) counts once, at its first
occurrence in the current child order, unless count_hard_links.
Iterative, so deep trees cannot exhaust the stack.