Function: archive-unique-fname

archive-unique-fname is a byte-compiled function defined in arc-mode.el.gz.

Signature

(archive-unique-fname FNAME DIR)

Documentation

Make sure a file FNAME can be created uniquely in directory DIR.

If FNAME can be uniquely created in DIR, it is returned unaltered. If FNAME is something our underlying filesystem can't grok, or if another file by that name already exists in DIR, a unique new name is generated using make-temp-file, and the generated name is returned.

Source Code

;; Defined in /usr/src/emacs/lisp/arc-mode.el.gz
;; -------------------------------------------------------------------------
;;; Section: Local archive copy handling

(defun archive-unique-fname (fname dir)
  "Make sure a file FNAME can be created uniquely in directory DIR.

If FNAME can be uniquely created in DIR, it is returned unaltered.
If FNAME is something our underlying filesystem can't grok, or if another
file by that name already exists in DIR, a unique new name is generated
using `make-temp-file', and the generated name is returned."
  (let ((fullname (expand-file-name fname dir))
	(alien (string-match file-name-invalid-regexp fname))
	(tmpfile
	 (expand-file-name
	  (if (if (fboundp 'msdos-long-file-names)
		  (not (msdos-long-file-names)))
	      "am"
	    "arc-mode.")
	  dir)))
    (if (or alien (file-exists-p fullname))
	(progn
	  ;; Make sure all the leading directories in
	  ;; archive-local-name exist under archive-tmpdir, so that
	  ;; the directory structure recorded in the archive is
	  ;; reconstructed in the temporary directory.
	  (make-directory (file-name-directory tmpfile) t)
	  (make-temp-file tmpfile))
      ;; Make sure all the leading directories in `fullname' exist
      ;; under archive-tmpdir.  This is necessary for nested archives
      ;; (`archive-extract' sets `archive-remote' to t in case
      ;; an archive occurs inside another archive).
      (make-directory (file-name-directory fullname) t)
      fullname)))