Skip to content

Commit

Permalink
Move try_get_hard_link_target to Header struct
Browse files Browse the repository at this point in the history
The function `try_get_hard_link_target` belong to the `Header` struct.
  • Loading branch information
bdrung committed Sep 4, 2024
1 parent b8e6c7b commit febd0f8
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,13 @@ impl Header {
file.seek_forward(skip.into())?;
Ok(())
}

fn try_get_hard_link_target<'a>(&self, seen_files: &'a SeenFiles) -> Option<&'a String> {
if self.nlink <= 1 {
return None;
}
seen_files.get(&self.ino_and_dev())
}
}

struct UserGroupCache {
Expand Down Expand Up @@ -586,13 +593,6 @@ fn from_mtime(mtime: u32) -> SystemTime {
std::time::UNIX_EPOCH + std::time::Duration::from_secs(mtime.into())
}

fn try_get_hard_link_target<'a>(header: &Header, seen_files: &'a SeenFiles) -> Option<&'a String> {
if header.nlink <= 1 {
return None;
}
seen_files.get(&header.ino_and_dev())
}

fn write_file<R: Read + SeekForward>(
cpio_file: &mut R,
header: &Header,
Expand All @@ -601,7 +601,7 @@ fn write_file<R: Read + SeekForward>(
log_level: u32,
) -> Result<()> {
let mut file;
if let Some(target) = try_get_hard_link_target(header, seen_files) {
if let Some(target) = header.try_get_hard_link_target(seen_files) {
if log_level >= LOG_LEVEL_DEBUG {
writeln!(
std::io::stderr(),
Expand Down

0 comments on commit febd0f8

Please sign in to comment.