Hi,

Please review the attached patch (for both CHICKEN 4 and 5).

All the best.
Mario
-- 
http://parenteses.org/mario
>From e3b976bb721ced6c3bd4ee15ec5a908de915157d Mon Sep 17 00:00:00 2001
From: Mario Domenech Goulart <[email protected]>
Date: Fri, 5 Aug 2016 23:15:23 +0200
Subject: [PATCH] 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.
---
 files.scm | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/files.scm b/files.scm
index e06cf20..43f92f9 100644
--- a/files.scm
+++ b/files.scm
@@ -343,7 +343,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)
-- 
2.1.4

_______________________________________________
Chicken-hackers mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/chicken-hackers

Reply via email to