aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
Diffstat (limited to 'lisp')
-rw-r--r--lisp/files.el19
1 files changed, 8 insertions, 11 deletions
diff --git a/lisp/files.el b/lisp/files.el
index 19573cdf7b2..b05d453b0e7 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -1407,14 +1407,17 @@ You can then use `write-region' to write new data into the file.
1407If DIR-FLAG is non-nil, create a new empty directory instead of a file. 1407If DIR-FLAG is non-nil, create a new empty directory instead of a file.
1408 1408
1409If SUFFIX is non-nil, add that at the end of the file name." 1409If SUFFIX is non-nil, add that at the end of the file name."
1410 (let ((absolute-prefix (expand-file-name prefix temporary-file-directory))) 1410 (let ((absolute-prefix
1411 (if (or (zerop (length prefix)) (member prefix '("." "..")))
1412 (concat (file-name-as-directory temporary-file-directory) prefix)
1413 (expand-file-name prefix temporary-file-directory))))
1411 (if (find-file-name-handler absolute-prefix 'write-region) 1414 (if (find-file-name-handler absolute-prefix 'write-region)
1412 (files--make-magic-temp-file prefix dir-flag suffix) 1415 (files--make-magic-temp-file absolute-prefix dir-flag suffix)
1413 (make-temp-file-internal absolute-prefix 1416 (make-temp-file-internal absolute-prefix
1414 (if dir-flag t) (or suffix ""))))) 1417 (if dir-flag t) (or suffix "")))))
1415 1418
1416(defun files--make-magic-temp-file (prefix &optional dir-flag suffix) 1419(defun files--make-magic-temp-file (absolute-prefix &optional dir-flag suffix)
1417 "Implement (make-temp-file PREFIX DIR-FLAG SUFFIX). 1420 "Implement (make-temp-file ABSOLUTE-PREFIX DIR-FLAG SUFFIX).
1418This implementation works on magic file names." 1421This implementation works on magic file names."
1419 ;; Create temp files with strict access rights. It's easy to 1422 ;; Create temp files with strict access rights. It's easy to
1420 ;; loosen them later, whereas it's impossible to close the 1423 ;; loosen them later, whereas it's impossible to close the
@@ -1423,13 +1426,7 @@ This implementation works on magic file names."
1423 (let (file) 1426 (let (file)
1424 (while (condition-case () 1427 (while (condition-case ()
1425 (progn 1428 (progn
1426 (setq file 1429 (setq file (make-temp-name absolute-prefix))
1427 (make-temp-name
1428 (if (zerop (length prefix))
1429 (file-name-as-directory
1430 temporary-file-directory)
1431 (expand-file-name prefix
1432 temporary-file-directory))))
1433 (if suffix 1430 (if suffix
1434 (setq file (concat file suffix))) 1431 (setq file (concat file suffix)))
1435 (if dir-flag 1432 (if dir-flag