Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,8 @@ assert_eq!(kind.extension(), "foo");
- **msi** - `application/x-ole-storage`
- **cpio** - `application/x-cpio`
- **par2** - `application/x-par2`
- **stdf** - `application/x-stdf`
- **atdf** - `application/x-atdf`

#### Book

Expand Down
15 changes: 15 additions & 0 deletions src/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,15 @@ matcher_map!(
"der",
matchers::app::is_der
),
// STDF (Archive type) must be placed here, before COFF matcher.
// STDF little endian starts with 0x00 0x02 which matches COFF IA64 (0x00 0x02).
// Since STDF checks 4 bytes (more specific) vs COFF's 2 bytes, STDF must be checked first.
(
MatcherType::Archive,
"application/x-stdf",
"stdf",
matchers::archive::is_stdf
),
(
MatcherType::App,
"application/x-executable",
Expand Down Expand Up @@ -606,6 +615,12 @@ matcher_map!(
"cpio",
matchers::archive::is_cpio
),
(
MatcherType::Archive,
"application/x-atdf",
"atdf",
matchers::archive::is_atdf
),
// Text
(
MatcherType::Text,
Expand Down
14 changes: 14 additions & 0 deletions src/matchers/archive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -322,3 +322,17 @@ pub fn is_cpio(buf: &[u8]) -> bool {
&& buf[4] == 0x30
&& buf[5] == 0x31) // newc format
}

/// Returns whether a buffer is an STDF file.
/// STDF = Standard Test Data Format (binary)
pub fn is_stdf(buf: &[u8]) -> bool {
buf.len() > 3
&& ((buf[0] == 0x00 && buf[1] == 0x02 && buf[2] == 0x00 && buf[3] == 0x0A) // Little endian
|| (buf[0] == 0x02 && buf[1] == 0x00 && buf[2] == 0x00 && buf[3] == 0x0A)) // Big endian
}

/// Returns whether a buffer is an ATDF file.
/// ATDF = Advanced Test Data Format (text)
pub fn is_atdf(buf: &[u8]) -> bool {
buf.len() > 4 && buf[..5] == *b"FAR:A"
}
5 changes: 5 additions & 0 deletions testdata/sample.atdf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FAR:A|4|2|
MIR:123456|DMASEC3171WCQ3_101_F7O|Test/ASEC/A1/OQC/REV101/|STOLSI-OQC-01|OQC
|10:44:54 26-Nov-2025|11:41:46 26-Nov-2025|stolsiop|P|0|07|||||||||R|F7O|||
||||||||||||||
MRR:10:28:39 3-Dec-2025|||
Binary file added testdata/sample_be.stdf
Binary file not shown.
Binary file added testdata/sample_le.stdf
Binary file not shown.
3 changes: 3 additions & 0 deletions tests/archive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,6 @@ test_format!(
"sample.skippable.zst"
);
test_format!(Archive, "application/x-par2", "par2", par2, "sample.par2");
test_format!(Archive, "application/x-stdf", "stdf", stdf_le, "sample_le.stdf");
test_format!(Archive, "application/x-stdf", "stdf", stdf_be, "sample_be.stdf");
test_format!(Archive, "application/x-atdf", "atdf", atdf, "sample.atdf");