diff --git a/src/map.rs b/src/map.rs index 1d92627..713b4c5 100644 --- a/src/map.rs +++ b/src/map.rs @@ -420,6 +420,12 @@ matcher_map!( "epub", matchers::archive::is_epub ), + ( + MatcherType::Archive, + "image/openraster", + "ora", + matchers::archive::is_ora + ), ( MatcherType::Archive, "application/zip", diff --git a/src/matchers/archive.rs b/src/matchers/archive.rs index 710ab99..7fe7668 100644 --- a/src/matchers/archive.rs +++ b/src/matchers/archive.rs @@ -3,6 +3,38 @@ pub fn is_epub(buf: &[u8]) -> bool { crate::book::is_epub(buf) } +pub fn is_ora(buf: &[u8]) -> bool { + buf.len() > 57 + && buf[0] == 0x50 + && buf[1] == 0x4B + && buf[2] == 0x3 + && buf[3] == 0x4 + && buf[30] == 0x6D + && buf[31] == 0x69 + && buf[32] == 0x6D + && buf[33] == 0x65 + && buf[34] == 0x74 + && buf[35] == 0x79 + && buf[36] == 0x70 + && buf[37] == 0x65 + && buf[38] == 0x69 + && buf[39] == 0x6D + && buf[40] == 0x61 + && buf[41] == 0x67 + && buf[42] == 0x65 + && buf[43] == 0x2F + && buf[44] == 0x6F + && buf[45] == 0x70 + && buf[46] == 0x65 + && buf[47] == 0x6E + && buf[48] == 0x72 + && buf[49] == 0x61 + && buf[50] == 0x73 + && buf[51] == 0x74 + && buf[52] == 0x65 + && buf[53] == 0x72 +} + /// Returns whether a buffer is a zip archive. pub fn is_zip(buf: &[u8]) -> bool { buf.len() > 3 diff --git a/testdata/sample.ora b/testdata/sample.ora new file mode 100644 index 0000000..b4d4906 Binary files /dev/null and b/testdata/sample.ora differ diff --git a/tests/archive.rs b/tests/archive.rs index f2f1e1d..8feebc4 100644 --- a/tests/archive.rs +++ b/tests/archive.rs @@ -9,3 +9,5 @@ test_format!( ); test_format!(Archive, "application/zstd", "zst", zst, "sample.tar.zst"); + +test_format!(Archive, "image/openraster", "ora", ora, "sample.ora");