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))
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
+
+fun inGroup {user, group} =
+ List.exists (fn x => x = user)
+ (Posix.SysDB.Group.members (Posix.SysDB.getgrnam group))
+ handle OS.SysErr _ => false
+
end