aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Cargo.toml3
-rw-r--r--src/lib.rs1
-rw-r--r--src/raw/mod.rs13
-rw-r--r--src/raw/parser.rs8
4 files changed, 22 insertions, 3 deletions
diff --git a/Cargo.toml b/Cargo.toml
index 7bc61e1..a1ab8b0 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -9,4 +9,5 @@ num-derive = "0.2"
quick-error = "1.2.1"
byteorder = "1"
fnv = "1.0.3"
-getset = "0.0.6" \ No newline at end of file
+getset = "0.0.6"
+zip = "0.4" \ No newline at end of file
diff --git a/src/lib.rs b/src/lib.rs
index 5875abf..c81a519 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -26,6 +26,7 @@ extern crate getset;
extern crate byteorder;
extern crate fnv;
extern crate num_traits;
+extern crate zip;
pub mod raw;
diff --git a/src/raw/mod.rs b/src/raw/mod.rs
index 7cbe483..7a079a1 100644
--- a/src/raw/mod.rs
+++ b/src/raw/mod.rs
@@ -6,6 +6,8 @@
//! functions whenever possible.
mod types;
+use zip::ZipArchive;
+
pub use self::types::{
Agent, CbtActivation, CbtBuffRemove, CbtCustomSkill, CbtEvent, CbtResult, CbtStateChange,
Language, Skill, IFF,
@@ -13,4 +15,13 @@ pub use self::types::{
pub mod parser;
-pub use self::parser::{parse_file, Evtc, ParseError};
+pub use self::parser::{parse_file, Evtc, ParseError, ParseResult};
+
+use std::io::{Read, Seek};
+
+/// Parse a complete log that was compressed as a zip file.
+pub fn parse_zip<T: Read + Seek>(input: &mut T) -> ParseResult<Evtc> {
+ let mut archive = ZipArchive::new(input)?;
+ let mut file = archive.by_index(0)?;
+ parse_file(&mut file)
+}
diff --git a/src/raw/parser.rs b/src/raw/parser.rs
index 8e931a2..97c0bc7 100644
--- a/src/raw/parser.rs
+++ b/src/raw/parser.rs
@@ -117,11 +117,17 @@ quick_error! {
MalformedHeader {
description("malformed header")
}
+ InvalidZip(err: ::zip::result::ZipError) {
+ from()
+ description("zip error")
+ display("Archive error: {}", err)
+ cause(err)
+ }
}
}
/// A type indicating the parse result.
-type ParseResult<T> = Result<T, ParseError>;
+pub type ParseResult<T> = Result<T, ParseError>;
/// Parse the header of an evtc file.
///