home *** CD-ROM | disk | FTP | other *** search
- /* Watch a file by notification
- pops up a requester when a file gets modified.
- USAGE: watch <file>
- EXAMPLE: run >NIL: watch >NIL: s:startup-sequence */
-
- OPT OSVERSION=37
-
- MODULE 'dos/notify'
-
- DEF nreq:PTR TO notifyrequest,sig,task,exists
-
- PROC main() /* make sure file is there: else we'll */
- IF (FileLength(arg)=-1) OR (arg[0]=0) /* never be notified */
- WriteF('file "\s" does not exist\n',arg)
- CleanUp(10)
- ENDIF
- nreq:=New(SIZEOF notifyrequest) /* memory is cleared */
- IF nreq=NIL THEN RETURN 20
- sig:=AllocSignal(-1) /* we want to be signalled */
- IF sig=-1 THEN RETURN 10
- task:=FindTask(0)
- nreq.name:=arg /* fill in structure */
- nreq.flags:=NRF_SEND_SIGNAL
- nreq.port:=task /* union port/task */
- nreq.signalnum:=sig
- IF StartNotify(nreq)
- WriteF('Now watching: "\s"\n',arg)
- Wait(Shl(1,sig))
- EasyRequestArgs(0,[20,0,0,'File "\s" modified!','Damn!'],0,[arg])
- EndNotify(nreq)
- ELSE
- WriteF('Could not watch "\s".\n',arg)
- ENDIF
- FreeSignal(sig)
- ENDPROC
-