Function: url-file-extension

url-file-extension is an autoloaded and byte-compiled function defined in url-util.el.gz.

Signature

(url-file-extension FNAME &optional X)

Documentation

Return the filename extension of FNAME.

If optional argument X is t, then return the basename of the file with the extension stripped off.

Source Code

;; Defined in /usr/src/emacs/lisp/url/url-util.el.gz
;;;###autoload
(defun url-file-extension (fname &optional x)
  "Return the filename extension of FNAME.
If optional argument X is t, then return the basename
of the file with the extension stripped off."
  (if (and fname
	   (setq fname (url-file-nondirectory fname))
	   (string-match "\\.[^./]+$" fname))
      (if x (substring fname 0 (match-beginning 0))
	(substring fname (match-beginning 0) nil))
    ;;
    ;; If fname has no extension, and x then return fname itself instead of
    ;; nothing. When caching it allows the correct .hdr file to be produced
    ;; for filenames without extension.
    ;;
    (if x
        fname
      "")))