I'm looking for a way to get notified as soon as a new file has been created. So I was wondering if boost has a way of monitoring files so I can send them off as soon as I receive them. This would have to work for Linux and windows. I saw a few posts which seem to indicate that its not there yet, but that was some time ago. Thanks,
I use http://www.highscore.de/*boost*/*file_monitor*.zip It isn't officially part of Boost, but has worked Ok for me on Linux & Windows. Regards Craig On 4 April 2013 23:19, SRD <software.research.development@gmail.com> wrote:
I'm looking for a way to get notified as soon as a new file has been created. So I was wondering if boost has a way of monitoring files so I can send them off as soon as I receive them. This would have to work for Linux and windows. I saw a few posts which seem to indicate that its not there yet, but that was some time ago.
Thanks, _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
I'm looking for a way to get notified as soon as a new file has been created. So I was wondering if boost has a way of monitoring files so I can send them off as soon as I receive them. This would have to work for Linux and windows. I saw a few posts which seem to indicate that its not there yet, but that was some time ago. Thanks, =========== Last I checked there is nothing provided by Boost (although there were murmurs of it being possible to add into Boost ASIO). However, there are OS-specific interfaces you can use for this, you would just need to provide different implementations depending on the platform. Have a google around for inotify (for Linux) and ReadDirectoryChangesW (for Windows). You should be able to find plenty of examples of their usage :) -Colin
On Fri, 05 Apr 2013 00:19:51 +0200, SRD <software.research.development@gmail.com> wrote:
I'm looking for a way to get notified as soon as a new file has been created. So I was wondering if boost has a way of monitoring files so I can send them off as soon as I receive them. This would have to work for Linux and windows. I saw a few posts which seem to indicate that its not there yet, but that was some time ago.
If you click on http://en.highscore.de/cpp/boost/asio.html and scroll down to the very end, you find a directory monitor. It's a Boost.Asio I/O service object I once created. I don't remember whether it does out of the box what you need. But then feel free to adapt it. :) HTH, Boris
Thank you for the suggestions. So after looking over the ASIO extension, I have basically this implemented in my project and though I see a change when I add a file to the directory being monitored, I see no futher changes. I'm trying to monitor a directory and when a file is added, I will then make mods to it and move it elsewhere. I'm new to boost, and my understanding is that this is being executed within a thread, and it acts like its blocking. Any help much appreciated. void create_file_handler(const boost::system:error_code &ec, const boost::asio::dir_monitor_event &ev) { cout << "file name: " << ev.filename << endl; cout << " type : " << ev.type << endl; // now edit file ... } // from main() boost::thread t; { boost::asio::io_service io_service; boost::asio::dir_monitor dm(io_service); dm.add_directory("C:\\Users\\SRD\\DirA"); boost::asio::dir_monitor_event ev = dm.monitor(); dm.async_monitor(create_file_handler); t = boost::thread(boost::bind(&boost::asio::io_service::run, boost::refio_service))); boost::system_time time = boost::get_system_time(); time += boost::posix_time::time_duration(0, 0, 1); boost::thread::sleep(time); } t.join(); io_service.reset(); // now do app stuff .. On Fri, Apr 5, 2013 at 4:39 PM, Boris Schaeling <boris@highscore.de> wrote:
On Fri, 05 Apr 2013 00:19:51 +0200, SRD <software.research.** development@gmail.com <software.research.development@gmail.com>> wrote:
I'm looking for a way to get notified as soon as a new file has been
created. So I was wondering if boost has a way of monitoring files so I can send them off as soon as I receive them. This would have to work for Linux and windows. I saw a few posts which seem to indicate that its not there yet, but that was some time ago.
If you click on http://en.highscore.de/cpp/**boost/asio.html<http://en.highscore.de/cpp/boost/asio.html>and scroll down to the very end, you find a directory monitor. It's a Boost.Asio I/O service object I once created. I don't remember whether it does out of the box what you need. But then feel free to adapt it. :)
HTH, Boris
______________________________**_________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/**mailman/listinfo.cgi/boost-**users<http://lists.boost.org/mailman/listinfo.cgi/boost-users>
participants (4)
-
Boris Schaeling
-
Colin Powers
-
Craig Henderson
-
SRD