Module fif::files

source ·
Expand description

File handling - scanning, detecting MIME types, and so on.

Constants§

Functions§

  • Determines whether or not a file is hidden by checking for a leading full stop.
  • Returns a list of known extensions for this MIME type, if any. This function uses the Mime’s “essence” rather than the Mime itself - mime_guess::get_mime_extensions ignores the type suffix, treating “image/svg+xml” as “image/svg”, and thus fails to find any extensions. Passing the essence_str (which includes the suffix) fixes this.
  • Tries to identify the MIME type of a file from a given path.
  • Scans a given directory with WalkDir, filters with wanted_file, checks for errors, and returns a vector of DirEntrys.
  • Inspects the given entry, returning a Findings on success and a ScanError on failure.
  • Takes a slice of DirEntrys and calls scan_file on each one, returning the results in a vector.
  • Returns true if a file matches the given criteria. This means checking whether the file’s extension appears in exts (if specified), potentially skipping over hidden files, and so on.