diff --git a/README.md b/README.md index cea0d80..2a1d91a 100644 --- a/README.md +++ b/README.md @@ -177,6 +177,7 @@ assert_eq!(kind.extension(), "foo"); - **zst** - `application/zstd` - **msi** - `application/x-ole-storage` - **cpio** - `application/x-cpio` +- **par2** - `application/x-par2` #### Book diff --git a/src/map.rs b/src/map.rs index cd0b9ad..ebf1428 100644 --- a/src/map.rs +++ b/src/map.rs @@ -443,6 +443,12 @@ matcher_map!( "application/x-tar", "tar", matchers::archive::is_tar + ), + ( + MatcherType::Archive, + "application/x-par2", + "par2", + matchers::archive::is_par2 ), ( MatcherType::Archive, diff --git a/src/matchers/archive.rs b/src/matchers/archive.rs index ff03ca3..02906d6 100644 --- a/src/matchers/archive.rs +++ b/src/matchers/archive.rs @@ -35,6 +35,18 @@ pub fn is_tar(buf: &[u8]) -> bool { && buf[261] == 0x72 } +pub fn is_par2(buf: &[u8]) -> bool { + buf.len() > 8 + && buf[0] == 0x50 + && buf[1] == 0x41 + && buf[2] == 0x52 + && buf[3] == 0x32 + && buf[4] == 0x00 + && buf[5] == 0x50 + && buf[6] == 0x4B + && buf[7] == 0x54 +} + /// Returns whether a buffer is a RAR archive. pub fn is_rar(buf: &[u8]) -> bool { buf.len() > 6 diff --git a/tests/archive.rs b/tests/archive.rs index 6c34ee5..28bef76 100644 --- a/tests/archive.rs +++ b/tests/archive.rs @@ -17,3 +17,4 @@ test_format!( zst_skip, "sample.skippable.zst" ); +test_format!(Archive, "application/x-par2", "par2", par2, "sample.par2");