#credentials #docker #container

binaryornot

Detect whether a file is binary or not

1 stable release

1.0.0 Jun 11, 2019

#1148 in Filesystem

Download history 838/week @ 2024-07-20 692/week @ 2024-07-27 637/week @ 2024-08-03 487/week @ 2024-08-10 12/week @ 2024-08-17 4/week @ 2024-09-07 11/week @ 2024-09-14 21/week @ 2024-09-21 14/week @ 2024-09-28 2/week @ 2024-10-05 15/week @ 2024-10-12 17/week @ 2024-10-19 22/week @ 2024-10-26 20/week @ 2024-11-02

74 downloads per month

MIT/Apache and LGPL-3.0

280KB
71 lines

Contains (Mach-o exe, 30KB) tests/isBinaryFile/grep, (WOFF font, 19KB) glyphiconshalflings-regular.woff

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