Allow mkstemp! to have optional "mode" argument

* m4/mkstemp.m4: Remove.
* lib/mkstemp.c: Remove.
* lib/mkostemp.c: New file.
* m4/mkostemp.m4: New file.
* lib/Makefile.am:
* m4/gnulib-cache.m4:
* m4/gnulib-comp.m4: Remove mkstemp module, replace with mkostemp.

* libguile/fports.h:
* libguile/fports.c (scm_i_mode_to_open_flags): Factor out helper to
  parse mode string to open flags.
  (scm_open_file_with_encoding): Use the new helper.
* libguile/filesys.c:
  (scm_i_mkstemp): Adapt to take optional second argument, being a mode
  string.  Use mkostemp.
  (scm_mkstemp): Backwards compatible shim that calls scm_i_mkstemp.

* doc/ref/posix.texi:
* NEWS: Update.

* module/system/base/compile.scm (call-with-output-file/atomic): Pass
  "wb" as mode, to cause O_BINARY to be added on MinGW.
This commit is contained in:
Andy Wingo 2016-07-16 15:34:41 +02:00
commit aae3561584
12 changed files with 149 additions and 147 deletions

View file

@ -954,7 +954,7 @@ another name if the file exists (error @code{EEXIST}).
@code{mkstemp!} below does that.
@end deffn
@deffn {Scheme Procedure} mkstemp! tmpl
@deffn {Scheme Procedure} mkstemp! tmpl [mode]
@deffnx {C Function} scm_mkstemp (tmpl)
@cindex temporary file
Create a new unique file in the file system and return a new buffered
@ -975,6 +975,10 @@ which is usual for ordinary file creation,
(chmod port (logand #o666 (lognot (umask))))
...)
@end example
The optional @var{mode} argument specifies a mode with which to open the
new file, as a string in the same format that @code{open-file} takes.
It defaults to @code{"w+"}.
@end deffn
@deffn {Scheme Procedure} tmpfile