Hi all, This is an old bug and I think it's a good idea to remove file-mkstemp from the Windows version of the posix unit. It's been broken from the beginning, and nobody noticed. Maybe nobody is using it (I hope!), but it could also be that people are using it and expecting it to return sensible values.
In any case, I opted for removing it because this is just extremely tricky to get right. We're better off removing it than keeping the broken version, so if you prefer to keep the procedure and want to do it properly, please write a proper patch. Normally I'd say we should put this in stability, but if anyone out there is (ab)using mkstemp by ignoring the FD and looking just at the filename, that would prevent their code from functioning altogether, so let's keep it safe and put it only in 4.10.0. Cheers, Peter -- http://www.more-magic.net
>From c60ec9b5d57af950d269a511b0a280e8c8f34430 Mon Sep 17 00:00:00 2001 From: Peter Bex <peter....@xs4all.nl> Date: Sat, 2 Aug 2014 14:52:15 +0200 Subject: [PATCH] Mark file-mkstemp as unimplemented on Windows --- NEWS | 2 ++ manual/Unit posix | 1 + posixwin.scm | 15 +-------------- 3 files changed, 4 insertions(+), 14 deletions(-) diff --git a/NEWS b/NEWS index 20ece38..266f91f 100644 --- a/NEWS +++ b/NEWS @@ -21,6 +21,8 @@ - Unit "posix": - set-file-position! now allows negative positions for seek/cur (thanks to Seth Alves). + - file-mkstemp has been marked as unimplemented on Windows (it never + worked, see #819) - Runtime system: - Removed several deprecated, undocumented parts of the C interface: diff --git a/manual/Unit posix b/manual/Unit posix index af88972..76e377e 100644 --- a/manual/Unit posix +++ b/manual/Unit posix @@ -1473,6 +1473,7 @@ Microsoft tools or with MinGW): create-symbolic-link read-symbolic-link file-truncate file-lock file-lock/blocking file-unlock file-test-lock + file-mkstemp create-fifo fifo? set-alarm! terminal-port? terminal-name diff --git a/posixwin.scm b/posixwin.scm index c41e18d..93cd1e3 100644 --- a/posixwin.scm +++ b/posixwin.scm @@ -198,7 +198,6 @@ readdir(DIR * dir) #endif /* ifndef __WATCOMC__ */ #ifdef __WATCOMC__ -# define mktemp _mktemp /* there is no P_DETACH in Watcom CRTL */ # define P_DETACH P_NOWAIT #endif @@ -256,7 +255,6 @@ C_free_arg_string(char **where) { #define C_open(fn, fl, m) C_fix(open(C_c_string(fn), C_unfix(fl), C_unfix(m))) #define C_read(fd, b, n) C_fix(read(C_unfix(fd), C_data_pointer(b), C_unfix(n))) #define C_write(fd, b, n) C_fix(write(C_unfix(fd), C_data_pointer(b), C_unfix(n))) -#define C_mkstemp(t) C_fix(mktemp(C_c_string(t))) #define C_flushall() C_fix(_flushall()) @@ -775,18 +773,6 @@ EOF (##sys#signal-hook #:file-error 'file-write "cannot write to file" fd size) ) n) ) ) ) -(define file-mkstemp - (lambda (template) - (##sys#check-string template 'file-mkstemp) - (let* ([buf (##sys#make-c-string template 'file-mkstemp)] - [fd (##core#inline "C_mkstemp" buf)] - [path-length (string-length buf)]) - (when (eq? -1 fd) - (##sys#update-errno) - (##sys#signal-hook #:file-error 'file-mkstemp "cannot create temporary file" template) ) - (values fd (##sys#substring buf 0 (fx- path-length 1) ) ) ) ) ) - - ;;; Directory stuff: (define-inline (create-directory-helper name) @@ -1555,6 +1541,7 @@ int is_bad_mmap(void* p) (define-unimplemented file-link) (define-unimplemented file-lock) (define-unimplemented file-lock/blocking) +(define-unimplemented file-mkstemp) (define-unimplemented file-select) (define-unimplemented file-test-lock) (define-unimplemented file-truncate) -- 1.7.10.4
_______________________________________________ Chicken-hackers mailing list Chicken-hackers@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-hackers