views:

82

answers:

4

Hello! I am looking for a way to make a program in C or C++ that detects if there was any files altered, renamed, moved or deleted in a specified directory for Linux systems. Is there a way to do that?

+1  A: 

Program against FAM. On current Linux systems this service is provided by gamin or a similar application.

Ignacio Vazquez-Abrams
I *think* FAM is deprecated, and that you should use inotify instead. Am I right?
static_rtti
FAM as a program is deprecated, but its *interface* is still provided by gamin.
Ignacio Vazquez-Abrams
Thanks, i will explore this possibility
petermlm
Is there any reason to use gamin instead of inotify directly? (cross-platform compatibility maybe?)
static_rtti
Yes, cross-platform compatibility would be the big reason. Not to a lot of platforms mind you, but better than just recentish versions of one.
Ignacio Vazquez-Abrams
+3  A: 

You want inotify (and its man page.)

Nathon
Thanks, i will explore this possibility too
petermlm
Well, I will go with this one
petermlm
+3  A: 

Look into inotify, I think it's still current.

You can also use a wrapping API, such as glib's GIO GFileMonitor.

unwind
This also looks good, I will explore it too. Thanks
petermlm
+2  A: 

You could also use Qt and its QFileSystemWatcher class which can be used quite easily.

tibur
Well I am quit a Qt user, but for this program I wanted to use something more like Inotify, but thanks!
petermlm