How to monitor a folder using C++

Hi
I want to write a C++ program which has to take input as folder name and a thread should monitor that folder and it has to print the file name which is added into that folder. I'm new to C++ in unix. So plese help me in this. Kindly provide me some good links learn about on how to monitor the particular directory.
Last edited on
Check out the File Alteration Manager.
The only portable way I know to do this is to check the mtime of the directory for changes, then rescan the directory every time a change is noticed. That's very inefficient though.

On Linux, there is the inotify(7) API, which makes monitoring directories for new files a snap.
I tried with the File Alteration Manager program given in
http://techpubs.sgi.com/library/tpl/cgi-bin/getdoc.cgi/0650/bks/SGI_Developer/books/IIDsktp_IG/sgi_html/ch08.html#LE15849-PARENT
in that they included fam.h , for that header file i'm getting the following error
Could not open include file<fam.h>.
can u help me in this?
It's possible you don't have FAM installed. You'll need to do that first.

It turned up in the default installation of RedHat 8. I only found it because I was trying to work out why 8 ran so much slower than 7.3. I thought it was horrible. If there's another method, you could try it, but that's what FAM does.
Topic archived. No new replies allowed.