Do you have a typical platform dependent issue you're battling with ? Ask it here. Make sure you mention your platform, compiler, and wxWidgets version.
In my wx application on windows 7, I want to watch only .webm files in dir. I want to get event when a .webm file is added to dir.
I tried wxFileSystemWatcher, but it works only when I give dir path and I get event before the file is copied completely. Code is as follows,
// in OnEventLoopEnter
m_watcher = new wxFileSystemWatcher();
m_watcher->SetOwner(this);
bool result = m_watcher->Add(wxFileName::FileName("E:\\Watch"), wxFSW_EVENT_CREATE);
I want that the add/create event comes for .webm files only and after they copied. Is this possible?
Obviously, the first issue is easy to work around, as you can filter out the files you are not interested in.
The second issue workaround would be more difficult. You would need to keep track of the files for which the modify event arrived and e.g. periodically test if they are closed already. But testing if the file is closed can be tricky in itself...
I couldn't find a direct way to get the event after file is copied but I did it using wxThreadHelper. I store the file path when wxFSW_EVENT_CREATE or wxFSW_EVENT_MODIFY comes and, in thread's Entry(), I keep checking if it can be opened. While file is being copied, I get last error 32 otherwise 0.
I trigger wxQueueEvent and do the work.
As you suggested, I filtered out the files which is not a .webm file.
How do you copy that file? can I suggest copying files with another extension that webm, then rename? Watcher can catch file and, waiting a second or so, work with it.
I just need learn a little bit more. Thank you for your help.