Cron and FTP queries
[hcoop/domtool2.git] / src / slave.sml
index b0148f1..64613ed 100644 (file)
@@ -56,7 +56,12 @@ fun registerPostHandler handler =
     end
 
 fun handleChanges fs = (!preHandler ();
-                       app (!fileHandler) fs;
+                       app (fn recd as {action, file, ...} =>
+                               (!fileHandler recd;
+                                if action = Delete andalso Posix.FileSys.access (file, []) then
+                                    OS.FileSys.remove file
+                                else
+                                    ())) fs;
                        !postHandler ())
 
 fun shell ss = OS.Process.isSuccess (OS.Process.system (String.concat ss))
@@ -176,4 +181,18 @@ fun writeList (fname, ls) =
        TextIO.closeOut outf
     end
 
+fun lineInFile fname line =
+    let
+       val inf = TextIO.openIn fname
+       val line' = line ^ "\n"
+
+       fun loop () =
+           case TextIO.inputLine inf of
+               NONE => false
+             | SOME line => line = line' orelse loop ()
+    in
+       loop ()
+       before TextIO.closeIn inf
+    end handle IO.Io _ => false
+
 end