MutableArchive

Struct MutableArchive 

Source
pub struct MutableArchive { /* private fields */ }
Expand description

A mutable handle to an MPQ archive that supports modification operations

Implementations§

Source§

impl MutableArchive

Source

pub fn open<P: AsRef<Path>>(path: P) -> Result<Self>

Open an archive for modification

This opens the archive file with read/write permissions and loads the existing archive structure.

§Examples
use wow_mpq::MutableArchive;

let mut archive = MutableArchive::open("data.mpq")?;
Source

pub fn archive(&self) -> &Archive

Get immutable access to the underlying archive

This allows reading files and querying archive information while the archive is open for modification.

Source

pub fn archive_mut(&mut self) -> &mut Archive

Get mutable access to the underlying archive

This allows operations that require mutable access such as reading files and listing entries. This is safe because MutableArchive has exclusive ownership of the Archive.

Source

pub fn debug_state(&self) -> (Option<usize>, Option<usize>)

Debug helper to check internal state

Source

pub fn read_file(&mut self, name: &str) -> Result<Vec<u8>>

Read a file from the archive

This method checks the modified state first, then falls back to the original archive. This ensures that renamed files can still be read correctly.

Source

pub fn list(&mut self) -> Result<Vec<FileEntry>>

List files in the archive

This is a convenience method that delegates to the underlying Archive. It allows listing files from a MutableArchive without having to call archive_mut() explicitly.

Source

pub fn find_file(&mut self, name: &str) -> Result<Option<FileInfo>>

Find a file in the archive

This method checks the modified state first, then falls back to the original archive. This ensures that removed/renamed files are handled correctly.

Source

pub fn verify_signature(&mut self) -> Result<SignatureStatus>

Verify the digital signature of the archive

This is a convenience method that delegates to the underlying Archive.

Source

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

Load and cache attributes from the (attributes) file

This is a convenience method that delegates to the underlying Archive.

Source

pub fn add_file<P: AsRef<Path>>( &mut self, source_path: P, archive_name: &str, options: AddFileOptions, ) -> Result<()>

Add a file from disk to the archive

§Parameters
  • source_path: Path to the file on disk to add
  • archive_name: Name for the file within the archive
  • options: Options controlling compression, encryption, etc.
§Examples
use wow_mpq::{MutableArchive, AddFileOptions};

let mut archive = MutableArchive::open("data.mpq")?;

// Add with default options
archive.add_file("texture.blp", "Textures\\new.blp", Default::default())?;

// Add with custom options
let options = AddFileOptions::new()
    .compression(wow_mpq::compression::CompressionMethod::Lzma)
    .encrypt();
archive.add_file("model.m2", "Models\\character.m2", options)?;
Source

pub fn add_file_data( &mut self, data: &[u8], archive_name: &str, options: AddFileOptions, ) -> Result<()>

Add a file from memory to the archive

§Parameters
  • data: File data to add
  • archive_name: Name for the file within the archive
  • options: Options controlling compression, encryption, etc.
Source

pub fn remove_file(&mut self, archive_name: &str) -> Result<()>

Remove a file from the archive

This marks the file as deleted in the hash table. The space is not reclaimed until compact() is called.

§Parameters
  • archive_name: Name of the file to remove
Source

pub fn rename_file(&mut self, old_name: &str, new_name: &str) -> Result<()>

Rename a file in the archive

§Parameters
  • old_name: Current name of the file
  • new_name: New name for the file
Source

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

Compact the archive to reclaim space from deleted files

This creates a new archive file with all active files copied over, removing any gaps from deleted files.

Source

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

Flush any pending changes to disk

This ensures all modifications are written to the archive file. This is automatically called when the archive is dropped.

Trait Implementations§

Source§

impl Debug for MutableArchive

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Drop for MutableArchive

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

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>,

Source§

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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V