From 4994a0e435849b268cea80863a62fbed14b3b602 Mon Sep 17 00:00:00 2001
From: Doug Coleman <doug.coleman@gmail.com>
Date: Fri, 29 Feb 2008 23:17:15 -0600
Subject: [PATCH] fix with-directory.  i thought i did this already..

---
 core/io/files/files-tests.factor | 2 ++
 core/io/files/files.factor       | 4 ++--
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/core/io/files/files-tests.factor b/core/io/files/files-tests.factor
index 92e148a854..850a30380b 100755
--- a/core/io/files/files-tests.factor
+++ b/core/io/files/files-tests.factor
@@ -121,3 +121,5 @@ USING: tools.test io.files io threads kernel continuations ;
 [ ] [ "copy-destination" temp-file delete-tree ] unit-test
 
 [ ] [ "copy-tree-test" temp-file delete-tree ] unit-test
+
+[ t ] [ cwd "misc" resource-path [ ] with-directory cwd = ] unit-test
diff --git a/core/io/files/files.factor b/core/io/files/files.factor
index e20437fa85..28f23b0de5 100755
--- a/core/io/files/files.factor
+++ b/core/io/files/files.factor
@@ -84,7 +84,7 @@ HOOK: cd io-backend ( path -- )
 HOOK: cwd io-backend ( -- path )
 
 : with-directory ( path quot -- )
-    swap cd cwd [ cd ] curry [ ] cleanup ; inline
+    cwd [ cd ] curry rot cd [ ] cleanup ; inline
 
 ! Creating directories
 HOOK: make-directory io-backend ( path -- )
@@ -223,4 +223,4 @@ HOOK: <file-appender> io-backend ( path -- stream )
         { [ winnt? ] [ "USERPROFILE" os-env ] }
         { [ wince? ] [ "" resource-path ] }
         { [ unix? ] [ "HOME" os-env ] }
-    } cond ;
\ No newline at end of file
+    } cond ;