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()))