X-Git-Url: https://git.nihav.org/?a=blobdiff_plain;ds=inline;f=nihav-registry%2Fsrc%2Fdetect.rs;h=6f67fbd7253502f17f82a212d8bfce2a6eb531a0;hb=55d852316872154db020827bd833fff7d5b49604;hp=2621000eb889edbd45e536f7b5613175bf313269;hpb=283abfa6154b38880dc6378d9a618aec4fc2eefe;p=nihav.git diff --git a/nihav-registry/src/detect.rs b/nihav-registry/src/detect.rs index 2621000..6f67fbd 100644 --- a/nihav-registry/src/detect.rs +++ b/nihav-registry/src/detect.rs @@ -282,6 +282,11 @@ const DETECTORS: &[DetectConditions] = &[ extensions: ".vmd", conditions: &[], }, + DetectConditions { + demux_name: "vx", + extensions: ".vx", + conditions: &[CheckItem{offs: 0, cond: &CC::Str(b"VXDS") }], + }, ]; /// Tries to detect container format. @@ -332,6 +337,22 @@ pub fn detect_format(name: &str, src: &mut ByteReader) -> Option<(&'static str, result } +/// Tries to detect container format for provided file name. +pub fn detect_format_by_name(name: &str) -> Option<(&'static str)> { + if name.is_empty() { + return None; + } + let lname = name.to_lowercase(); + for detector in DETECTORS { + for ext in detector.extensions.split(',') { + if lname.ends_with(ext) { + return Some(detector.demux_name); + } + } + } + None +} + #[cfg(test)] mod test { use super::*;