mpq_rs/lib.rs
1//! A library for reading and writing Blizzard's proprietary MoPaQ archive format.
2//!
3//! Currently, `ceres-mpq` only supports reading and writing Version 1 MoPaQ
4//! archives, as this is the only version of the format still actively encountered
5//! in the wild, used by Warcraft III custom maps.
6//!
7//! For this reason, no effort was made to support features found in newer
8//! versions of the format, though this may change in the future if there is
9//! a need for this.
10//!
11//! `ceres-mpq` provides no support to edit existing archives yet, thought it may in the future.
12//!
13//! # Supported features
14//!
15//! Not the whole range of MPQ features is supported yet for reading archives. Notably:
16//!
17//! * IMA ADPCM compression is unsupported. This is usually present on `.wav` files.
18//! * Huffman coding compression is unsupported. This is usually present on `.wav` files.
19//! * PKWare DCL compression is unsupported. However, I haven't seen any WC3 maps that use it.
20//! * Single-unit files are unsupported.
21//! * Checksums and file attributes are not checked or read.
22//!
23//! Additionally, for writing archives:
24//! * You cannot choose which compression type to use for added files in [Creator](struct.Creator.html). DEFLATE is used by default.
25//!
26//! # Protected MPQs
27//!
28//! In Warcraft III, it is not uncommon to encounter so-called "protected maps" which use various
29//! obfuscations and hacks that are designed in such a manner that they can be read by WC3's
30//! built-in MPQ implementation, but will trip up other implementations.
31//!
32//! **No effort is made to work around those "protections" in `ceres-mpq`**. In particular,
33//! `ceres-mpq` is likely to fail when trying to read a protected MPQ which has explicitly
34//! subverted the MPQ archive structure in some manner.
35//!
36//! If you need a library with good support for reading protected maps, please refer to [StormLib](http://www.zezula.net/en/mpq/stormlib.html).
37//!
38//! # Example
39//!
40//! ```
41//! # use ceres_mpq::Creator;
42//! # use ceres_mpq::FileOptions;
43//! # use ceres_mpq::Archive;
44//! # use std::io::{Cursor, Read, Write, Seek, SeekFrom};
45//! # use std::error::Error;
46//! # fn main() -> Result<(), Box<Error>> {
47//! let buf: Vec<u8> = Vec::new();
48//! let mut cursor = Cursor::new(buf);
49//!
50//! // creating an archive
51//! let mut creator = Creator::default();
52//! creator.add_file("hello.txt", "hello world!",
53//! FileOptions {
54//! encrypt: false,
55//! compress: true,
56//! adjust_key: false
57//! }
58//! );
59//! creator.write(&mut cursor)?;
60//!
61//! cursor.seek(SeekFrom::Start(0))?;
62//!
63//! // reading an archive
64//! let mut archive = Archive::open(&mut cursor)?;
65//! let file = archive.read_file("hello.txt")?;
66//!
67//! assert_eq!(file.as_slice(), b"hello world!");
68//! # Ok(())
69//! # }
70//! ```
71
72#![allow(dead_code)]
73
74pub mod core;
75pub mod run;
76
77pub use core::archive::Archive;
78pub use core::creator::Creator;
79pub use core::creator::FileOptions;
80pub use core::error::MpqError;