Skip to content

Commit

Permalink
Par2 - added support
Browse files Browse the repository at this point in the history
  • Loading branch information
gr211 committed Dec 10, 2024
1 parent 66c1890 commit 2e1bdd3
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 6 additions & 0 deletions src/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
12 changes: 12 additions & 0 deletions src/matchers/archive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions tests/archive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ test_format!(
zst_skip,
"sample.skippable.zst"
);
test_format!(Archive, "application/x-par2", "par2", par2, "sample.par2");

0 comments on commit 2e1bdd3

Please sign in to comment.