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 themime_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 theMime
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 theessence_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 withwanted_file
, checks for errors, and returns a vector ofDirEntry
s. - Returns
true
if a file matches the given criteria. This means checking whether the file’s extension appears inexts
(if specified), potentially skipping over hidden files, and so on.