pub struct MutableArchive { /* private fields */ }Expand description
A mutable handle to an MPQ archive that supports modification operations
Implementations§
Source§impl MutableArchive
impl MutableArchive
Sourcepub fn open<P: AsRef<Path>>(path: P) -> Result<Self>
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")?;Sourcepub fn archive(&self) -> &Archive
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.
Sourcepub fn archive_mut(&mut self) -> &mut Archive
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.
Sourcepub fn debug_state(&self) -> (Option<usize>, Option<usize>)
pub fn debug_state(&self) -> (Option<usize>, Option<usize>)
Debug helper to check internal state
Sourcepub fn read_file(&mut self, name: &str) -> Result<Vec<u8>>
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.
Sourcepub fn list(&mut self) -> Result<Vec<FileEntry>>
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.
Sourcepub fn find_file(&mut self, name: &str) -> Result<Option<FileInfo>>
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.
Sourcepub fn verify_signature(&mut self) -> Result<SignatureStatus>
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.
Sourcepub fn load_attributes(&mut self) -> Result<()>
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.
Sourcepub fn add_file<P: AsRef<Path>>(
&mut self,
source_path: P,
archive_name: &str,
options: AddFileOptions,
) -> Result<()>
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 addarchive_name: Name for the file within the archiveoptions: 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)?;Sourcepub fn add_file_data(
&mut self,
data: &[u8],
archive_name: &str,
options: AddFileOptions,
) -> Result<()>
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 addarchive_name: Name for the file within the archiveoptions: Options controlling compression, encryption, etc.
Sourcepub fn remove_file(&mut self, archive_name: &str) -> Result<()>
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
Sourcepub fn rename_file(&mut self, old_name: &str, new_name: &str) -> Result<()>
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 filenew_name: New name for the file
Trait Implementations§
Source§impl Debug for MutableArchive
impl Debug for MutableArchive
Auto Trait Implementations§
impl Freeze for MutableArchive
impl RefUnwindSafe for MutableArchive
impl Send for MutableArchive
impl Sync for MutableArchive
impl Unpin for MutableArchive
impl UnwindSafe for MutableArchive
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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