[fpc-pascal] Watching for file change

waldo kitty wkitty42 at windstream.net
Fri Apr 11 21:29:09 CEST 2014


On 4/11/2014 3:06 PM, Krzysztof wrote:
> Hi,
>
> Does FPC have some file watching solution? I need this only for linux.
> I need notifications:
> - File/folder changed / removed / added in watched directory. I have
> idea how to do this in thread loop but maybe FPC has OS solution

i'm interested in this, as well... i have an app in perl that i'm considering 
rewriting in FPC... in that app, i had to specifically grab the attributes of 
the files the app watches and compare those values to previously stored values...

in perl:

     if ($check_file eq $alert_file) {            # If we're testing the alert 
file and
 
($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,$blksize,$blocks) 
= stat($check_file);
         if ($size < $prev_alert_size) {          # the filesize is less than 
last we checked,
             &write_log (2,"Alert filename changed. Reopening $alert_file");
             close (ALERT);                       # we need to close and
             open (ALERT, "$alert_file");         # reopen it.
             $prev_alert_size = $size;
         } else {
             $prev_alert_size = $size;
         }
     }

hopefully there is something similar to perl's stat() routine...

-- 
NOTE: No off-list assistance is given without prior approval.
       Please keep mailing list traffic on the list unless
       private contact is specifically requested and granted.



More information about the fpc-pascal mailing list