Skip to content

Commit 6424c63

Browse files
authored
Merge pull request #105 from grumlimited/par2
Par2 - added support
2 parents cba46eb + 4b58ab6 commit 6424c63

File tree

5 files changed

+20
-0
lines changed

5 files changed

+20
-0
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ assert_eq!(kind.extension(), "foo");
179179
- **lz4** - `application/x-lz4`
180180
- **msi** - `application/x-ole-storage`
181181
- **cpio** - `application/x-cpio`
182+
- **par2** - `application/x-par2`
182183

183184
#### Book
184185

src/map.rs

+6
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,12 @@ matcher_map!(
444444
"tar",
445445
matchers::archive::is_tar
446446
),
447+
(
448+
MatcherType::Archive,
449+
"application/x-par2",
450+
"par2",
451+
matchers::archive::is_par2
452+
),
447453
(
448454
MatcherType::Archive,
449455
"application/vnd.rar",

src/matchers/archive.rs

+12
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,18 @@ pub fn is_tar(buf: &[u8]) -> bool {
3535
&& buf[261] == 0x72
3636
}
3737

38+
pub fn is_par2(buf: &[u8]) -> bool {
39+
buf.len() > 8
40+
&& buf[0] == 0x50
41+
&& buf[1] == 0x41
42+
&& buf[2] == 0x52
43+
&& buf[3] == 0x32
44+
&& buf[4] == 0x00
45+
&& buf[5] == 0x50
46+
&& buf[6] == 0x4B
47+
&& buf[7] == 0x54
48+
}
49+
3850
/// Returns whether a buffer is a RAR archive.
3951
pub fn is_rar(buf: &[u8]) -> bool {
4052
buf.len() > 6

testdata/sample.par2

24 Bytes
Binary file not shown.

tests/archive.rs

+1
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,4 @@ test_format!(
2525
zst_skip,
2626
"sample.skippable.zst"
2727
);
28+
test_format!(Archive, "application/x-par2", "par2", par2, "sample.par2");

0 commit comments

Comments
 (0)