Function tree_magic::match_filepath

source ·
pub fn match_filepath(mimetype: &str, filepath: &Path) -> bool
Expand description

Check if the given filepath matches the given MIME type.

Returns true or false if it matches or not, or an Error if the file could not be read. If the given MIME type is not known, it will always return false.

Examples

use std::path::Path;

// Get path to a GIF file
let path: &Path = Path::new("tests/image/gif");

// Check if the MIME and the file are a match
let result = tree_magic::match_filepath("image/gif", path);
assert_eq!(result, true);