chicken-janitors
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Chicken-janitors] #819: file-mkstemp on windows is broken


From: Chicken Trac
Subject: [Chicken-janitors] #819: file-mkstemp on windows is broken
Date: Thu, 19 Apr 2012 21:32:34 -0000

#819: file-mkstemp on windows is broken
----------------------------+-----------------------------------------------
 Reporter:  zbigniew        |       Owner:       
     Type:  defect          |      Status:  new  
 Priority:  minor           |   Milestone:       
Component:  core libraries  |     Version:  4.7.x
 Keywords:                  |  
----------------------------+-----------------------------------------------
 posixwin.scm file-mkstemp utilizes C_mkstemp which is defined as

 #define C_mkstemp(t)        C_fix(mktemp(C_c_string(t)))

 However mktemp returns a char* pointer to the updated template, not an FD
 as file-mkstemp expects.  It seems that mkstemp() was just changed to
 mktemp() on Windows without checking if it does the same thing.

 In my tests on mingw, the template requires exactly 6 Xs.  Otherwise it
 will return NULL (which is translated to FD 0).  On success it returns a
 pointer which is translated to a nonsense FD.

 {{{
 #;1> (file-mkstemp "test.XXX")
 0
 "test.960"
 ; 2 values
 #;1> (file-mkstemp "test.XXXXXX")
 2253780
 "test.a01960"
 ; 2 values
 }}}

 I think file-mkstemp should throw unimplemented error on Windows instead.
 Alternatively it could probably be implemented by using mktemp and file-
 open with (+ open/creat open/excl) in a loop, but you have to get the
 permissions right and I'm sure there are even more hairy details.

-- 
Ticket URL: <http://bugs.call-cc.org/ticket/819>
Chicken Scheme <http://www.call-with-current-continuation.org/>
Chicken Scheme is a compiler for the Scheme programming language.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]