[fpc-pascal] Watching for file change

Graeme Geldenhuys mailinglists at geldenhuys.co.uk
Sat Apr 12 01:32:14 CEST 2014


On 2014-04-11 20:06, Krzysztof wrote:
> idea how to do this in thread loop but maybe FPC has OS solution

As the others have said, the OS solutions are very version/distro
dependent - especially under Linux which changes underlying
functionality every 6 months or so (so damn annoying).

A cross-platform solution is very easy to implement. It might not be as
efficient as an OS specific solution, but works just as well. I've
implemented such a solution in fpGUI's demo IDE application. It run in a
separate thread. You can register what to watch - files or directories,
and it fires an OnChange event when changes are detected. If memory
serves me well, I also used a CRC check on files to detect if the file
content changed (and date/time or file size wasn't).

Michael van Canneyt's article (URL quoted earlier) also covers the topic.


Regards,
  - Graeme -

-- 
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/



More information about the fpc-pascal mailing list