added read_file, write_file;
authorwenzelm
Wed, 06 Aug 1997 14:09:50 +0200
changeset 3624 36e19fce289e
parent 3623 e843c1d6f9e1
child 3625 33f718b4f7bf
added read_file, write_file;
src/Pure/library.ML
--- a/src/Pure/library.ML	Wed Aug 06 11:58:50 1997 +0200
+++ b/src/Pure/library.ML	Wed Aug 06 14:09:50 1997 +0200
@@ -770,13 +770,30 @@
                         else error (msg_fn x)
   in  asl l  end;
 
-(*for the "test" target in Makefiles -- signifies successful termination*)
+
+(* read / write files *)
+
+fun read_file name =
+  let
+    val instream  = TextIO.openIn name;
+    val intext = TextIO.inputAll instream;
+  in
+    TextIO.closeIn instream;
+    intext
+  end;
+
+fun write_file name txt =
+  let
+    val outstream = TextIO.openOut name;
+  in
+    TextIO.output (outstream, txt);
+    TextIO.closeOut outstream
+  end;
+
+
+(*for the "test" target in IsaMakefiles -- signifies successful termination*)
 fun maketest msg =
-  (writeln msg; 
-   let val os = TextIO.openOut "test" 
-   in  TextIO.output (os, "Test examples ran successfully\n");
-       TextIO.closeOut os
-   end);
+  (writeln msg; write_file "test" "Test examples ran successfully\n");
 
 
 (*print a list surrounded by the brackets lpar and rpar, with comma separator
@@ -816,7 +833,7 @@
   (writeln ("\n**** Starting " ^ fname ^ " ****"); use fname;
    writeln ("\n**** Finished " ^ fname ^ " ****")));
 
-(*For Makefiles: use the file, but exit with error code if errors found.*)
+(*use the file, but exit with error code if errors found.*)
 fun exit_use fname = use fname handle _ => exit 1;