/// Local File Header Signature
const LFHS: [u8; 4] = [0x50, 0x4b, 0x03, 0x04];
/// End of central directory signature
const ECDS: [u8; 4] = [0x50, 0x4b, 0x05, 0x06];
/// ZIP detection logic is very simple and is based on this document: https://en.wikipedia.org/wiki/ZIP_(file_format)
/// First we look for the **Local File Header Signature**, which is `[0x50, 0x4b, 0x03, 0x04]`,
/// then do a backward lookup (sliding window) for the **End of central directory signature**, which is
/// `[0x50, 0x4b, 0x05, 0x06]`.
pub(crate) fn is_zip(start: usize, buffer: &Vec<u8>) -> bool {
// This check ensures that the zip-file does have the 4 byte initial marker
// and the 22 bytes (plus n, for comments) EOCD record
return if (buffer.len() - start) < 22 + 4 {
false
/// Checks whether data inside buffer has magic number of a binary file.
/// This is not a 100% accurate check, but may be sufficient in most of the cases.
pub(crate) fn is_binary(start: usize, buffer: &Vec<u8>) -> bool {
return if let Some(_) = infer::get(&buffer[start..]) {
true