[wxMSW][wx3.0.3] Watching dir for webm files

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.
Post Reply
Rudra
Filthy Rich wx Solver
Filthy Rich wx Solver
Posts: 224
Joined: Fri Sep 13, 2013 2:59 pm

[wxMSW][wx3.0.3] Watching dir for webm files

Post by Rudra »

Hi,

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,

Code: Select all

// 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?

Thanks,
R.
PB
Part Of The Furniture
Part Of The Furniture
Posts: 4204
Joined: Sun Jan 03, 2010 5:45 pm

Re: [wxMSW][wx3.0.3] Watching dir for webm files

Post by PB »

I believe it is not.

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...
Rudra
Filthy Rich wx Solver
Filthy Rich wx Solver
Posts: 224
Joined: Fri Sep 13, 2013 2:59 pm

Re: [wxMSW][wx3.0.3] Watching dir for webm files

Post by Rudra »

Thanks for the reply.

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.

Thanks for the help.
R.
User avatar
marcelinux
Knows some wx things
Knows some wx things
Posts: 40
Joined: Thu Nov 07, 2013 9:59 pm
Location: Madrid, Spain

Re: [wxMSW][wx3.0.3] Watching dir for webm files

Post by marcelinux »

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