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.
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.
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.