comparison lisp/url/url-util.el @ 79558:ba4da6f08090

(url-make-private-file): New function.
author Glenn Morris <rgm@gnu.org>
date Tue, 11 Dec 2007 05:50:26 +0000
parents 5299839279f5
children 9c0b3f269b92
comparison
equal deleted inserted replaced
79557:3d0d9d7bb356 79558:ba4da6f08090
521 (goto-char (point-min)) 521 (goto-char (point-min))
522 (unless url-current-mime-headers 522 (unless url-current-mime-headers
523 (set (make-local-variable 'url-current-mime-headers) 523 (set (make-local-variable 'url-current-mime-headers)
524 (mail-header-extract))))) 524 (mail-header-extract)))))
525 525
526 (defun url-make-private-file (file)
527 "Make FILE only readable and writable by the current user.
528 Creates FILE and its parent directories if they do not exist."
529 (let ((dir (file-name-directory file)))
530 (when dir
531 ;; For historical reasons.
532 (make-directory dir t)))
533 ;; Based on doc-view-make-safe-dir.
534 (condition-case nil
535 (let ((umask (default-file-modes)))
536 (unwind-protect
537 (progn
538 (set-default-file-modes #o0600)
539 (with-temp-buffer
540 (write-region (point-min) (point-max)
541 file nil 'silent nil 'excl)))
542 (set-default-file-modes umask)))
543 (file-already-exists
544 (if (file-symlink-p file)
545 (error "Danger: `%s' is a symbolic link" file))
546 (set-file-modes file #o0600))))
547
526 (provide 'url-util) 548 (provide 'url-util)
527 549
528 ;; arch-tag: 24352abc-5a5a-412e-90cd-313b26bed5c9 550 ;; arch-tag: 24352abc-5a5a-412e-90cd-313b26bed5c9
529 ;;; url-util.el ends here 551 ;;; url-util.el ends here