summaryrefslogtreecommitdiff
path: root/module/system
diff options
context:
space:
mode:
authorAndy Wingo <wingo@pobox.com>2021-03-10 20:35:58 +0100
committerAndy Wingo <wingo@pobox.com>2021-03-10 20:40:10 +0100
commit85433fc2b122dc78342c3c83941949d1d9318399 (patch)
tree2fff776765468df861dc8a8c5e80f551b4905a5f /module/system
parent89a299102ff3597a48febe1fb6d3097fddcda40e (diff)
downloadguile-85433fc2b122dc78342c3c83941949d1d9318399.tar.gz
Add mkstemp; undocument mkstemp!
* doc/ref/posix.texi (File System): Update to document mkstemp only. * libguile/filesys.c: Make a mkstemp that doesn't modify the input template. Instead the caller has to get the file name from port-filename. (scm_mkstemp): Use the new mkstemp to implement mkstemp!. Can't deprecate yet though as the replacement hasn't been there for long enough. * libguile/posix.c (scm_tempnam): Update to mention mkstemp instead. * module/system/base/compile.scm (call-with-output-file/atomic): Use mkstemp. * test-suite/tests/posix.test: * test-suite/tests/r6rs-files.test: Use mkstemp. * NEWS: Update.
Diffstat (limited to 'module/system')
-rw-r--r--module/system/base/compile.scm12
1 files changed, 6 insertions, 6 deletions
diff --git a/module/system/base/compile.scm b/module/system/base/compile.scm
index 567765dc0..9ec9cbb0f 100644
--- a/module/system/base/compile.scm
+++ b/module/system/base/compile.scm
@@ -1,6 +1,6 @@
;;; High-level compiler interface
-;; Copyright (C) 2001,2005,2008-2013,2016,2020 Free Software Foundation, Inc.
+;; Copyright (C) 2001,2005,2008-2013,2016,2020,2021 Free Software Foundation, Inc.
;;; This library is free software; you can redistribute it and/or modify it
;;; under the terms of the GNU Lesser General Public License as published by
@@ -60,8 +60,8 @@
;; emacs: (put 'call-with-output-file/atomic 'scheme-indent-function 1)
(define* (call-with-output-file/atomic filename proc #:optional reference)
- (let* ((template (string-append filename ".XXXXXX"))
- (tmp (mkstemp! template "wb")))
+ (let* ((tmp (mkstemp (string-append filename ".XXXXXX") "wb"))
+ (tmpname (port-filename tmp)))
(call-once
(lambda ()
(with-throw-handler #t
@@ -71,12 +71,12 @@
;; work on systems without fchmod, like MinGW.
(let ((perms (or (false-if-exception (stat:perms (stat reference)))
(lognot (umask)))))
- (chmod template (logand #o0666 perms)))
+ (chmod tmpname (logand #o0666 perms)))
(close-port tmp)
- (rename-file template filename))
+ (rename-file tmpname filename))
(lambda args
(close-port tmp)
- (delete-file template)))))))
+ (delete-file tmpname)))))))
(define (ensure-language x)
(if (language? x)