Boost logo

Boost Users :

Subject: [Boost-users] ASIO file monitoring help
From: SRD (software.research.development_at_[hidden])
Date: 2013-04-10 14:43:15


I'm using an ASIO extention that was suggested for file monitoring. I've
added this to my project and though I see a change when I add a file to the
directory being monitored, I see no futher changes thereafter.

Can anyone offer some insight as to how this should work? 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 within 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 ..



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net