If the mime package is installed, call mime::guess_type(), otherwise
use the system command file --mime-type to obtain the MIME type of a file.
Typically, the file command exists on *nix. On Windows, the command should
exist if Cygwin or Rtools is installed. If it is not found, .NET's
MimeMapping class will be used instead (which requires the .NET framework).
Usage
mime_type(x, use_mime = loadable("mime"), empty = "text/plain")
Arguments
- x
A vector of file paths.
- use_mime
Whether to use the mime package.
- empty
The MIME type for files without extensions (e.g., Makefile).
If NA, the type will be obtained from system command. This argument is
used only for use_mime = FALSE.
Value
A character vector of MIME types.
Note
When querying the MIME type via the system command, the result will be
cached to xfun:::cache_dir(). This will make future queries much faster,
since running the command in real time can be a little slow.