Function extract_archive

Source
pub fn extract_archive<P: AsRef<Path>>(
    data: &[u8],
    output_path: P,
    force: bool,
) -> Result<ExtractOutcome, ExtractError>
Expand description

A convenience function to extract an archive in a single call.

This is a wrapper around Decrypter::extract with automatic initialization.

§Parameters

  • data: The content of the archive file.
  • output_path: The output path for extracted files.
  • force: If true, existing files will be overwritten.

§Returns

  • Ok(ExtractOutcome::Extracted) if files were successfully extracted.
  • Ok(ExtractOutcome::FilesExist) if files already exist and force is false.
  • Err(ExtractError::InvalidHeader) for invalid header.
  • Err(ExtractError::InvalidEngine) for invalid header engine type byte.

§Example

use rpgmad_lib::extract_archive;

let data: Vec<u8> = std::fs::read("Game.rgssad").unwrap();
extract_archive(&data, "output", true).unwrap();