Browse Source

AIFF support w/ infer backend

edition-2021
Lynne Megido 3 months ago
parent
commit
74ae55ac52
Signed by: lynnesbian
GPG Key ID: F0A184B5213D9F90
  1. 2
      CHANGELOG.md
  2. 21
      src/mime_db.rs
  3. 2
      src/parameters.rs

2
CHANGELOG.md

@ -5,6 +5,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
[Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## Unreleased
### Added
- AIFF (Audio Interchange File Format, a PCM audio format like WAV) detection to [`infer`]
### Other
- Refactoring - split fif into main.rs and lib.rs, moved file-related functionality (directory scanning, etc.) into
files module, removed string module, etc.

21
src/mime_db.rs

@ -43,9 +43,23 @@ cfg_if! {
buf.len() >= 34 && buf.starts_with(b"RPA-") && buf[7] == b' ' && buf[24] ==b' '
});
info.add("audio/x-aiff", "aiff", |buf| {
// as added by https://github.com/bojand/infer/pull/48/files
// this should be removed when (if) that PR is accepted
buf.len() > 11
&& buf[0] == 0x46
&& buf[1] == 0x4F
&& buf[2] == 0x52
&& buf[3] == 0x4D
&& buf[8] == 0x41
&& buf[9] == 0x49
&& buf[10] == 0x46
&& buf[11] == 0x46
});
info.add("image/svg+xml", "svg", |buf| {
// before doing the moderately expensive SVG check, we should make sure that the input is actually SGML-ish
// by "SGML-ish", i mean starts with anywhere from zero to ∞-1 whitespace characters, and then a less than sign,
// before doing the moderately expensive SVG check, we should make sure that the input is actually SGML-ish,
// by which i mean, starts with anywhere from zero to ∞-1 whitespace characters, and then a less than sign,
// and then there's some other stuff we don't care about right now
// so, here comes our fancy pants """""SGML-ish validator"""""
@ -72,9 +86,6 @@ cfg_if! {
.any(|buf| identifiers.iter().any(|id| buf.starts_with(id)))
});
// unmut
let info = info;
Self { db: info }
}

2
src/parameters.rs

@ -30,8 +30,6 @@ pub enum OutputFormat {
Json,
}
// TODO: convert this to macro style?: https://docs.rs/clap/3.0.0-beta.2/clap/index.html#using-macros
#[derive(Clap, Debug)]
#[allow(clippy::struct_excessive_bools)]
#[clap(

Loading…
Cancel
Save