Function tags_from_path

Source
pub fn tags_from_path<P: AsRef<Path>>(path: P) -> Result<TagSet>
Expand description

Identify a file from its filesystem path.

This is the most comprehensive identification method, providing a superset of information from other methods. It analyzes:

  1. File type (regular file, directory, symlink, socket)
  2. File permissions (executable vs non-executable)
  3. Filename and extension patterns
  4. File content (binary vs text detection)
  5. Shebang lines for executable files

§Arguments

  • path - Path to the file to identify

§Returns

A set of tags identifying the file type and characteristics.

§Errors

Returns IdentifyError::PathNotFound if the path doesn’t exist, or IdentifyError::IoError for other I/O failures.

§Examples

use file_identify::tags_from_path;

let tags = tags_from_path(&file_path).unwrap();
assert!(tags.contains("file"));
assert!(tags.contains("python"));
assert!(tags.contains("text"));