Function: mh-file-mime-type
mh-file-mime-type is an autoloaded and byte-compiled function defined
in mh-mime.el.gz.
Signature
(mh-file-mime-type FILENAME)
Documentation
Return MIME type of FILENAME from file command.
Returns nil if file command not on system.
Source Code
;; Defined in /usr/src/emacs/lisp/mh-e/mh-mime.el.gz
;;;###mh-autoload
(defun mh-file-mime-type (filename)
"Return MIME type of FILENAME from file command.
Returns nil if file command not on system."
(cond
((not (mh-have-file-command))
nil) ;no file command, exit now
((not (and (file-exists-p filename)
(file-readable-p filename)))
nil) ;no file or not readable, ditto
(t
(let ((tmp-buffer (get-buffer-create mh-temp-buffer)))
(with-current-buffer tmp-buffer
(unwind-protect
(progn
(call-process "file" nil '(t nil) nil "-b" "-i"
(expand-file-name filename))
(goto-char (point-min))
(if (not (re-search-forward mh-media-type-regexp nil t))
nil
(mh-file-mime-type-substitute (match-string 0) filename)))
(kill-buffer tmp-buffer)))))))