From a3c81e9830745cdca4335029d5e3a9fd7f1b3653 Mon Sep 17 00:00:00 2001 From: "A. Molzer" <5550310+197g@users.noreply.github.com> Date: Mon, 14 Jul 2025 18:25:21 +0200 Subject: [PATCH] Add Directory::is_empty for completeness --- src/directory.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/directory.rs b/src/directory.rs index 4a33d92..6a2d0ff 100644 --- a/src/directory.rs +++ b/src/directory.rs @@ -27,6 +27,8 @@ pub struct Directory { } impl Directory { + /// Create a directory in an initial state without entries. Note that an empty directory can + /// not be encoded in a file, it must contain at least one entry. pub fn empty() -> Self { Directory { entries: BTreeMap::new(), @@ -72,6 +74,12 @@ impl Directory { self.entries.len() } + /// Check if there are any entries in this directory. Note that an empty directory can not be + /// encoded in the file, it must contain at least one entry. + pub fn is_empty(&self) -> bool { + self.entries.is_empty() + } + /// Get the pointer to the next IFD, if it was defined. pub fn next(&self) -> Option { self.next_ifd.map(|n| IfdPointer(n.get()))