I have a folder called “Datas”. This folder has a subfolder called “Inbox” inside of which there are multiple “.txt” files. This “Datas” folder can be modified and in the end there will be multiple subfolders with “Inbox” subfolders and “.txt” files. I need to monitor the “Datas” folder and the “.txt” file from the “Inbox” folder. How can I do that?
INotify is just monitoring a folder and pops events when subfolders are created. How to pop events when “.txt” files are created (in which folder)?
I need C or C++ code but I am stuck. I do not know how to solve this.
From the inotify manpage:
It can be done by catching this event.
Again from the manpage:
So, you will need to do the recursive part yourself. You can start by looking an example from here. You should also have a look at the project notify-tools
EXAMPLE as asked in comments: It monitors
/tmp/inotify1&/tmp/inotify2for new files created & displays the eventsTest run: