Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2011-09

File monitoring Linux

8 messages · 5 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Mattias Gaertner

Hi,

I'm searching some pascal code for file monitoring for Linux. That means getting notified if a file in a directory or its sub directories was modified.
I found some hints that people started it, but I can't find the result. Any hints are greatly appreciated.

Or has someone already implemented some bindings for inotify?

Mattias

Martin Schreiber
to Mattias Gaertner
Mattias Gaertner wrote 10 lines
Hi, I'm searching some pascal code for file monitoring for Linux. That means getting notified if a file in a directory or its sub directories was modified. I found some hints that people started it, but I can't find the result. Any hints are greatly appreciated. Or has someone already implemented some bindings for inotify?

MSEgui has an implementation based on signals because inotify is not available on old kernels.
lib/common/sysutils/msefilechange.pas.

Martin

Martin Schreiber
to Graeme Geldenhuys: Word of caution... I still haven't tracked down why MSEide doesn't notify me or detect…
Graeme Geldenhuys wrote 11 lines
On 13/09/2011 14:14, Martin Schreiber wrote: >> > MSEgui has an implementation based on signals because inotify is not > available on old kernels. > lib/common/sysutils/msefilechange.pas. Word of caution... I still haven't tracked down why MSEide doesn't notify me or detect external file changes under 64-bit Linux. So somewhere there might still be an implementation bug.

Works for me on openSUSE x64, I could not reproduce the problems, sorry.

Martin

Graeme Geldenhuys
to Martin Schreiber: MSEgui has an implementation based on signals because inotify is not available on old…
Martin Schreiber wrote
> MSEgui has an implementation based on signals because inotify is not available on old kernels. lib/common/sysutils/msefilechange.pas.

Word of caution... I still haven't tracked down why MSEide doesn't notify me or detect external file changes under 64-bit Linux. So somewhere there might still be an implementation bug.

Regards,
- Graeme -

fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://fpgui.sourceforge.net/
Mattias Gaertner
to Martin Schreiber: MSEgui has an implementation based on signals because inotify is not available on old…
Show quoted text 13 lines
Am 13.09.2011 13:05, schrieb Mattias Gaertner: > Hi, > > I'm searching some pascal code for file monitoring for Linux. That means > getting notified if a file in a directory or its sub directories was > modified. > I found some hints that people started it, but I can't find the result. > Any hints are greatly appreciated. > > Or has someone already implemented some bindings for inotify? > MSEgui has an implementation based on signals because inotify is not available on old kernels.

Thanks. Luckily I don't need to support old kernels.

lib/common/sysutils/msefilechange.pas.

Does this work with thousands of sub directories?

Mattias

cobines
to Mattias Gaertner: I'm searching some pascal code for file monitoring for Linux. That means getting notified…

We have an implementation based on inotify in our project:

http://doublecmd.svn.sourceforge.net/viewvc/doublecmd/branches/0.5/src/platform/unix/inotify.pp http://doublecmd.svn.sourceforge.net/viewvc/doublecmd/branches/0.5/src/platform/ufilesystemwatcher.pas

It has only been tested to work on directories.

However, as the docs say:

"Inotify monitoring of directories is not recursive: to monitor subdirectories under a directory, additional watches must be created."

Our implementation is directed at handling few directories, so you would need to optimize it to handle thousands of directories.

cobines
Michael Schneider
to Mattias Gaertner: I'm searching some pascal code for file monitoring for Linux. That means getting notified…
Mattias Gaertner wrote 12 lines
Hi, I'm searching some pascal code for file monitoring for Linux. That means getting notified if a file in a directory or its sub directories was modified. I found some hints that people started it, but I can't find the result. Any hints are greatly appreciated. Or has someone already implemented some bindings for inotify? Mattias

Here is something i had in my bookmarks ;)
dont know if its still valid
http://www.friends-of-fpc.org/research/LinuxProgramming/inotify/