Skip to main content

match_filepath

Function 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);