petermlm
petermlm

Reputation: 940

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?

Upvotes: 6

Views: 947

Answers (4)

tibur
tibur

Reputation: 11636

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

Upvotes: 2

nmichaels
nmichaels

Reputation: 50943

You want inotify (and its man page.)

Upvotes: 6

unwind
unwind

Reputation: 399713

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

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

Upvotes: 4

Ignacio Vazquez-Abrams
Ignacio Vazquez-Abrams

Reputation: 798486

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

Upvotes: 3

Related Questions