]> gitweb.factorcode.org Git - factor.git/commitdiff
Add a combinator to make a unique directory, set that to the current and temp directo...
authorDoug Coleman <doug.coleman@gmail.com>
Fri, 11 Jun 2010 21:54:30 +0000 (16:54 -0500)
committerDoug Coleman <doug.coleman@gmail.com>
Mon, 14 Jun 2010 00:34:17 +0000 (19:34 -0500)
basis/io/files/unique/unique.factor

index 5bf89b95207cf15fe068fb8c2fd1c1796cd2c29f..7652bfcfd075f299ad75b625945ab71cf26ebc59 100644 (file)
@@ -2,7 +2,7 @@
 ! See http://factorcode.org/license.txt for BSD license.
 USING: arrays combinators continuations fry io io.backend
 io.directories io.directories.hierarchy io.files io.pathnames
-kernel math math.bitwise math.parser namespaces random
+kernel locals math math.bitwise math.parser namespaces random
 sequences system vocabs.loader ;
 IN: io.files.unique
 
@@ -78,9 +78,10 @@ PRIVATE>
 
 : temporary-file ( -- path ) "" unique-file ;
 
-: with-working-directory ( path quot -- )
-    over make-directories
-    dupd '[ _ _ with-temporary-directory ] with-directory ; inline
+:: cleanup-unique-working-directory ( quot -- )
+    unique-directory :> path
+    path [ path quot with-temporary-directory ] with-directory
+    path delete-tree ; inline
 
 {
     { [ os unix? ] [ "io.files.unique.unix" ] }