Skip to content

Commit

Permalink
Merge pull request #296 from wcampbell0x2a/remove-custom-debug
Browse files Browse the repository at this point in the history
Remove custom debug for DirEntry and DirectoryIndex
  • Loading branch information
wcampbell0x2a authored Oct 25, 2023
2 parents 7ac5add + 8c2034b commit 26dffb9
Showing 1 changed file with 2 additions and 27 deletions.
29 changes: 2 additions & 27 deletions src/dir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
//! For each directory inode, the directory table stores a linear list of all entries,
//! with references back to the inodes that describe those entries.
use core::fmt;
use std::ffi::OsStr;
use std::os::unix::prelude::OsStrExt;
use std::path::{Component, Path};
Expand Down Expand Up @@ -48,8 +47,7 @@ impl Dir {
}
}

// TODO: derive our own Debug, with name()
#[derive(DekuRead, DekuWrite, Clone, PartialEq, Eq)]
#[derive(Debug, DekuRead, DekuWrite, Clone, PartialEq, Eq)]
#[deku(endian = "endian", ctx = "endian: deku::ctx::Endian")]
pub struct DirEntry {
/// An offset into the uncompressed inode metadata block.
Expand All @@ -66,18 +64,6 @@ pub struct DirEntry {
pub(crate) name: Vec<u8>,
}

impl fmt::Debug for DirEntry {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("DirEntry")
.field("offset", &self.offset)
.field("inode_offset", &self.inode_offset)
.field("t", &self.t)
.field("name_size", &self.name_size)
.field("name", &self.name())
.finish()
}
}

impl DirEntry {
pub fn name(&self) -> Result<&Path, BackhandError> {
// allow root and nothing else
Expand All @@ -94,7 +80,7 @@ impl DirEntry {
}
}

#[derive(DekuRead, DekuWrite, Clone, PartialEq, Eq)]
#[derive(Debug, DekuRead, DekuWrite, Clone, PartialEq, Eq)]
#[deku(endian = "endian", ctx = "endian: deku::ctx::Endian")]
pub struct DirectoryIndex {
/// This stores a byte offset from the first directory header to the current header,
Expand All @@ -108,17 +94,6 @@ pub struct DirectoryIndex {
pub(crate) name: Vec<u8>,
}

impl fmt::Debug for DirectoryIndex {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("DirectoryIndex")
.field("index", &self.index)
.field("start", &self.start)
.field("name_size", &self.name_size)
.field("name", &self.name())
.finish()
}
}

impl DirectoryIndex {
pub fn name(&self) -> String {
std::str::from_utf8(&self.name).unwrap().to_string()
Expand Down

0 comments on commit 26dffb9

Please sign in to comment.