use_dir and exit_use_dir now change the CWD only temporarily
authorclasohm
Tue, 23 Apr 1996 12:38:16 +0200
changeset 1670 d706a6dce930
parent 1669 e56cdf711729
child 1671 608196238072
use_dir and exit_use_dir now change the CWD only temporarily
src/Pure/Thy/thy_read.ML
--- a/src/Pure/Thy/thy_read.ML	Mon Apr 22 15:42:20 1996 +0200
+++ b/src/Pure/Thy/thy_read.ML	Tue Apr 23 12:38:16 1996 +0200
@@ -1354,18 +1354,24 @@
   in Symtab.lookup (d2, id) end;
 
 
-(*CD to a directory and load its ROOT.ML file;
+(*Temporarily enter a directory and load its ROOT.ML file;
   also do some work for HTML generation*)
-fun use_dir dirname =
-  (cd dirname;
-   if !make_html then init_html() else ();
-   use "ROOT.ML";
-   finish_html());
+local
 
-fun exit_use_dir dirname =
-  (cd dirname;
-   if !make_html then init_html() else ();
-   exit_use "ROOT.ML";
-   finish_html());
+  fun gen_use_dir use_cmd dirname =
+    let val old_dir = pwd ();
+    in cd dirname;
+       if !make_html then init_html() else ();
+       use_cmd "ROOT.ML";
+       finish_html();
+       cd old_dir
+    end;
+
+in
+
+  val use_dir = gen_use_dir use;
+  val exit_use_dir = gen_use_dir exit_use;
+
+end
 
 end;