]> xenbits.xensource.com Git - xcp/xen-api-libs.git/commitdiff
CA-44731: Rewrite file_lines_iter in terms of file_lines_fold.
authorDavid Scott <dave.scott@eu.citrix.com>
Tue, 12 Oct 2010 11:07:32 +0000 (12:07 +0100)
committerDavid Scott <dave.scott@eu.citrix.com>
Tue, 12 Oct 2010 11:07:32 +0000 (12:07 +0100)
Signed-off-by: David Scott <dave.scott@eu.citrix.com>
stdext/unixext.ml

index 1e6c2744ec922f09473103679e808d9277c06a88..1e162cdda51a274be6cf69ecc0339c855791bac3 100644 (file)
@@ -98,16 +98,7 @@ let file_lines_fold f start file_path =
                (fun () -> fold start)
                (fun () -> close_in input)
 
-let file_lines_iter f file_path =
-       let input = open_in file_path in
-       try
-               while true do
-                       let line = input_line input in
-                       f line
-               done
-       with
-               | End_of_file -> close_in input
-               | exn -> close_in input; raise exn
+let file_lines_iter f file_path = file_lines_fold (fun () line -> ignore(f line)) () file_path
 
 let readfile_line = file_lines_iter