app (!fileHandler) fs;
!postHandler ())
+fun shell ss = OS.Process.isSuccess (OS.Process.system (String.concat ss))
+
+fun shellF (ss, msg) =
+ let
+ val s = String.concat ss
+ in
+ if OS.Process.isSuccess (OS.Process.system s) then
+ ()
+ else
+ ErrorMsg.error NONE (msg s)
+ end
+
+fun concatTo p fname =
+ let
+ fun visitDir dname =
+ let
+ val dir = Posix.FileSys.opendir dname
+
+ fun loop () =
+ case Posix.FileSys.readdir dir of
+ NONE => Posix.FileSys.closedir dir
+ | SOME fname' =>
+ let
+ val path = OS.Path.joinDirFile {dir = dname, file = fname'}
+ in
+ if Posix.FileSys.ST.isDir (Posix.FileSys.stat path) then
+ visitDir path
+ else if p fname' then
+ shellF ([Config.cat, " ", path, " >>", fname],
+ fn cl => "Error concatenating: " ^ cl)
+ else
+ ();
+ loop ()
+ end
+ in
+ TextIO.closeOut (TextIO.openOut fname);
+ loop ()
+ end
+ in
+ visitDir Config.resultRoot
+ end
+
end