Function: url-make-private-file

url-make-private-file is a byte-compiled function defined in url-util.el.gz.

Signature

(url-make-private-file FILE)

Documentation

Make FILE only readable and writable by the current user.

Creates FILE and its parent directories if they do not exist.

Source Code

;; Defined in /usr/src/emacs/lisp/url/url-util.el.gz
(defun url-make-private-file (file)
  "Make FILE only readable and writable by the current user.
Creates FILE and its parent directories if they do not exist."
  (let ((dir (file-name-directory file)))
    (when dir
      ;; For historical reasons.
      (make-directory dir t)))
  ;; Based on doc-view-make-safe-dir.
  (condition-case nil
      (with-file-modes #o0600
        (with-temp-buffer
          (write-region (point-min) (point-max) file nil 'silent nil 'excl)))
    (file-already-exists
     (set-file-modes file #o0600 'nofollow))))