~ chicken-core (chicken-5) 045f51386a07ca9a5df6597610f62caa42eb82b2


commit 045f51386a07ca9a5df6597610f62caa42eb82b2
Author:     Mario Domenech Goulart <mario.goulart@gmail.com>
AuthorDate: Fri Aug 5 23:15:23 2016 +0200
Commit:     Evan Hanson <evhan@foldling.org>
CommitDate: Thu Aug 11 21:54:42 2016 +1200

    create-temporary-directory: don't try to mkdir if a file with the same name exists
    
    By checking for the existence of a _directory_ in
    create-temporary-directory, the following program would eventually
    cause a runtime error, as a _file_ with the same name would exist:
    
      (use files)
    
      (let loop ()
        (create-temporary-file "")
        (create-temporary-directory)
        (loop))
    
      Error: (create-temporary-directory) cannot create temporary directory
      - File exists: ...
    
    Use file-exists? instead of directory-exists? to work around this
    issue.
    
    Signed-off-by: Evan Hanson <evhan@foldling.org>

diff --git a/files.scm b/files.scm
index 00753980..4caf665d 100644
--- a/files.scm
+++ b/files.scm
@@ -183,7 +183,7 @@ EOF
 		     (number->string n 16)
 		     "."
 		     (##sys#number->string (##sys#fudge 33)))))) ; PID
-	  (if (directory-exists? pn) 
+	  (if (file-exists? pn)
 	      (loop)
 	      (let ((r (##core#inline "C_mkdir" (##sys#make-c-string pn 'create-temporary-directory))))
 		(if (eq? r 0)
Trap