Module fif::files[][src]

Expand description

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

Constants

The number of bytes to read if the file couldn’t be identified from its first INITIAL_BUF_SIZE bytes. Used in the mime_type function.

The number of bytes to read initially when identifying a file’s MIME type. Used in the mime_type function.

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.