Function: files--make-magic-temp-file

files--make-magic-temp-file is a byte-compiled function defined in files.el.gz.

Signature

(files--make-magic-temp-file ABSOLUTE-PREFIX &optional DIR-FLAG SUFFIX TEXT)

Documentation

Implement (make-temp-file ABSOLUTE-PREFIX DIR-FLAG SUFFIX TEXT).

This implementation works on magic file names.

Source Code

;; Defined in /usr/src/emacs/lisp/files.el.gz
(defun files--make-magic-temp-file (absolute-prefix
                                    &optional dir-flag suffix text)
  "Implement (make-temp-file ABSOLUTE-PREFIX DIR-FLAG SUFFIX TEXT).
This implementation works on magic file names."
  ;; Create temp files with strict access rights.  It's easy to
  ;; loosen them later, whereas it's impossible to close the
  ;; time-window of loose permissions otherwise.
  (with-file-modes ?\700
    (let ((contents (if (stringp text) text ""))
          file)
      (while (condition-case ()
		 (progn
		   (setq file (make-temp-name absolute-prefix))
		   (if suffix
		       (setq file (concat file suffix)))
		   (if dir-flag
		       (make-directory file)
		     (write-region contents nil file nil 'silent nil 'excl))
		   nil)
	       (file-already-exists t))
	;; the file was somehow created by someone else between
	;; `make-temp-name' and `write-region', let's try again.
	nil)
      file)))