Struct cfb::CompoundFile

source ·
pub struct CompoundFile<F> { /* private fields */ }
Expand description

A compound file, backed by an underlying reader/writer (such as a File or Cursor).

Implementations§

source§

impl<F> CompoundFile<F>

source

pub fn version(&self) -> Version

Returns the CFB format version used for this compound file.

source

pub fn root_entry(&self) -> Entry

Returns information about the root storage object. This is equivalent to self.entry("/").unwrap() (but always succeeds).

source

pub fn entry<P: AsRef<Path>>(&self, path: P) -> Result<Entry>

Given a path within the compound file, get information about that stream or storage object.

source

pub fn read_root_storage(&self) -> Entries<'_, F>

Returns an iterator over the entries within the root storage object. This is equivalent to self.read_storage("/").unwrap() (but always succeeds).

source

pub fn read_storage<P: AsRef<Path>>(&self, path: P) -> Result<Entries<'_, F>>

Returns an iterator over the entries within a storage object.

source

pub fn walk(&self) -> Entries<'_, F>

Returns an iterator over all entries within the compound file, starting from and including the root entry. The iterator walks the storage tree in a preorder traversal. This is equivalent to self.walk_storage("/").unwrap() (but always succeeds).

source

pub fn walk_storage<P: AsRef<Path>>(&self, path: P) -> Result<Entries<'_, F>>

Returns an iterator over all entries under a storage subtree, including the given path itself. The iterator walks the storage tree in a preorder traversal.

source

pub fn exists<P: AsRef<Path>>(&self, path: P) -> bool

Returns true if there is an existing stream or storage at the given path, or false if there is nothing at that path.

source

pub fn is_stream<P: AsRef<Path>>(&self, path: P) -> bool

Returns true if there is an existing stream at the given path, or false if there is a storage or nothing at that path.

source

pub fn is_storage<P: AsRef<Path>>(&self, path: P) -> bool

Returns true if there is an existing storage at the given path, or false if there is a stream or nothing at that path.

source

pub fn into_inner(self) -> F

Consumes the CompoundFile, returning the underlying reader/writer.

source§

impl<F: Seek> CompoundFile<F>

source

pub fn open_stream<P: AsRef<Path>>(&mut self, path: P) -> Result<Stream<F>>

Opens an existing stream in the compound file for reading and/or writing (depending on what the underlying file supports).

source§

impl<F: Read + Seek> CompoundFile<F>

source

pub fn open(inner: F) -> Result<CompoundFile<F>>

Opens an existing compound file, using the underlying reader. If the underlying reader also supports the Write trait, then the CompoundFile object will be writable as well.

source

pub fn open_strict(inner: F) -> Result<CompoundFile<F>>

Like open(), but is stricter when parsing and will return an error if the file violates the CFB spec in any way (which many CFB files in the wild do). This is mainly useful for validating a CFB file or implemention (such as this crate itself) to help ensure compatibility with other readers.

source§

impl<F: Read + Write + Seek> CompoundFile<F>

source

pub fn create(inner: F) -> Result<CompoundFile<F>>

Creates a new compound file with no contents, using the underlying reader/writer. The reader/writer should be initially empty.

source

pub fn create_with_version( version: Version, inner: F ) -> Result<CompoundFile<F>>

Creates a new compound file of the given version with no contents, using the underlying writer. The writer should be initially empty.

source

pub fn create_storage<P: AsRef<Path>>(&mut self, path: P) -> Result<()>

Creates a new, empty storage object (i.e. “directory”) at the provided path. The parent storage object must already exist.

source

pub fn create_storage_all<P: AsRef<Path>>(&mut self, path: P) -> Result<()>

Recursively creates a storage and all of its parent storages if they are missing.

source

pub fn remove_storage<P: AsRef<Path>>(&mut self, path: P) -> Result<()>

Removes the storage object at the provided path. The storage object must exist and have no children.

source

pub fn remove_storage_all<P: AsRef<Path>>(&mut self, path: P) -> Result<()>

Recursively removes a storage and all of its children. If called on the root storage, recursively removes all of its children but not the root storage itself (which cannot be removed).

source

pub fn set_storage_clsid<P: AsRef<Path>>( &mut self, path: P, clsid: Uuid ) -> Result<()>

Sets the CLSID for the storage object at the provided path. (To get the current CLSID for a storage object, use self.entry(path)?.clsid().)

source

pub fn create_stream<P: AsRef<Path>>(&mut self, path: P) -> Result<Stream<F>>

Creates and returns a new, empty stream object at the provided path. If a stream already exists at that path, it will be replaced by the new stream. The parent storage object must already exist.

source

pub fn create_new_stream<P: AsRef<Path>>( &mut self, path: P ) -> Result<Stream<F>>

Creates and returns a new, empty stream object at the provided path. Returns an error if a stream already exists at that path. The parent storage object must already exist.

source

pub fn remove_stream<P: AsRef<Path>>(&mut self, path: P) -> Result<()>

Removes the stream object at the provided path.

source

pub fn set_state_bits<P: AsRef<Path>>( &mut self, path: P, bits: u32 ) -> Result<()>

Sets the user-defined bitflags for the object at the provided path. (To get the current state bits for an object, use self.entry(path)?.state_bits().)

source

pub fn touch<P: AsRef<Path>>(&mut self, path: P) -> Result<()>

Sets the modified time for the object at the given path to now. Has no effect when called on the root storage.

source

pub fn flush(&mut self) -> Result<()>

Flushes all changes to the underlying file.

Trait Implementations§

source§

impl<F: Debug> Debug for CompoundFile<F>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<F> Freeze for CompoundFile<F>

§

impl<F> RefUnwindSafe for CompoundFile<F>

§

impl<F> Send for CompoundFile<F>
where F: Send + Sync,

§

impl<F> Sync for CompoundFile<F>
where F: Send + Sync,

§

impl<F> Unpin for CompoundFile<F>

§

impl<F> UnwindSafe for CompoundFile<F>

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.