Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

c++ program to watch directory for alterations

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?

like image 964
petermlm Avatar asked Aug 27 '10 14:08

petermlm


3 Answers

You want inotify (and its man page.)

like image 68
nmichaels Avatar answered Nov 20 '22 01:11

nmichaels


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

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

like image 21
unwind Avatar answered Nov 20 '22 02:11

unwind


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

like image 3
Ignacio Vazquez-Abrams Avatar answered Nov 20 '22 02:11

Ignacio Vazquez-Abrams