added write_list, append_list;
authorwenzelm
Wed, 06 Jul 2005 10:41:47 +0200
changeset 16713 be5763901788
parent 16712 c7d1c79d921c
child 16714 d9e3ef66b38c
added write_list, append_list;
src/Pure/General/file.ML
--- a/src/Pure/General/file.ML	Wed Jul 06 10:41:46 2005 +0200
+++ b/src/Pure/General/file.ML	Wed Jul 06 10:41:47 2005 +0200
@@ -22,6 +22,8 @@
   val read: Path.T -> string
   val write: Path.T -> string -> unit
   val append: Path.T -> string -> unit
+  val write_list: Path.T -> string list -> unit
+  val append_list: Path.T -> string list -> unit
   val eq: Path.T * Path.T -> bool
   val copy: Path.T -> Path.T -> unit
   val copy_dir: Path.T -> Path.T -> unit
@@ -107,18 +109,21 @@
   let val y = f x handle exn => (g x; raise exn)
   in g x; y end;
 
-fun output txt stream = TextIO.output (stream, txt);
+fun output txts stream = List.app (fn txt => TextIO.output (stream, txt)) txts;
 
 in
 
 fun read path =
   fail_safe TextIO.inputAll TextIO.closeIn (TextIO.openIn (platform_path path));
 
-fun write path txt =
-  fail_safe (output txt) TextIO.closeOut (TextIO.openOut (platform_path path));
+fun write_list path txts =
+  fail_safe (output txts) TextIO.closeOut (TextIO.openOut (platform_path path));
 
-fun append path txt =
-  fail_safe (output txt) TextIO.closeOut (TextIO.openAppend (platform_path path));
+fun append_list path txts =
+  fail_safe (output txts) TextIO.closeOut (TextIO.openAppend (platform_path path));
+
+fun write path txt = write_list path [txt];
+fun append path txt = append_list path [txt];
 
 end;