#credentials #container #docker

binaryornot

Detect whether a file is binary or not

1 stable release

1.0.0 Jun 11, 2019

#865 in Filesystem

Download history 16/week @ 2023-12-06 51/week @ 2023-12-13 23/week @ 2023-12-20 221/week @ 2023-12-27 413/week @ 2024-01-03 410/week @ 2024-01-10 420/week @ 2024-01-17 577/week @ 2024-01-24 696/week @ 2024-01-31 733/week @ 2024-02-07 597/week @ 2024-02-14 802/week @ 2024-02-21 516/week @ 2024-02-28 508/week @ 2024-03-06 741/week @ 2024-03-13 513/week @ 2024-03-20

2,370 downloads per month

MIT/Apache and LGPL-3.0

280KB
71 lines

Contains (Mach-o exe, 30KB) tests/isBinaryFile/grep

binaryornot

Build Status

A Rust port of binaryornot, letting you detect whether a file is binary or text.

Usage

Add the following to your cargo.toml:

[dependencies]
binaryornot = "1.0"
use binaryornot;

if binaryornot::is_binary("/path/to/some/file").expect("unable to read file") {
    println!("a binary!");
}

Limitations

Due to relying on the encoding crate for detecting different possible text encodings, UTF-32 will not be correctly detected as text, unlike in the original Python binaryornot implementation.

Licence

As indicated in the cargo.toml, this library can be consumed either under the MIT or Apache 2.0 licences. However, it should be noted that one of its dependencies, chardet, is licenced under the LGPL, meaning that any program statically linking it must also be distributed under the LGPL.

Dependencies

~4MB
~43K SLoC