Home » Community » Newbie corner » Need help with algorythm
Need help with algorythm [message #40455] |
Sun, 04 August 2013 19:02  |
lectus
Messages: 329 Registered: September 2006 Location: Brazil
|
Senior Member |
|
|
I need to watch when files are modified.
Do you have ideas how can I implement this in U++?
|
|
|
Re: Need help with algorythm [message #40456 is a reply to message #40455] |
Sun, 04 August 2013 19:57   |
|
lectus wrote on Sun, 04 August 2013 19:02 | I need to watch when files are modified.
Do you have ideas how can I implement this in U++?
|
Depends a lot on your exact case. Is it GUI or CLI app? What platform(s)? How soon do you need to know about file being modified?
Assuming multiplatform GUI app, then for most purposes you can probably be just fine with using something like SetTimeCallback(-1000, callback(MyFunc)), where MyFunc would look like
void MyFunc() {
static FileTime last = GetFileTime("somefile");
FileTime current = GetFileTime("somefile");
if (last == current)
return;
last = current;
// do actual work here
}
Of course, polling is not really efficient thing to do... On Linux you can use inotify to get a callback whenever file changes, on Windows you could use FileSystemWatcher or something. Both should cut down both the overhead from polling and the time till you notice the change and can react. The price is writing more code if you need it multiplatform... If you do this thouhg, it would be nice to create generalized class or function for this that could be added to U++ 
Best regards,
Honza
|
|
|
|
Re: Need help with algorythm [message #40459 is a reply to message #40457] |
Mon, 05 August 2013 06:54   |
|
Sender Ghost wrote on Sun, 04 August 2013 21:41 | Hello, Jan.
dolik.rce wrote on Sun, 04 August 2013 19:57 | If you do this though, it would be nice to create generalized class or function for this that could be added to U++
|
There is such bazaar package, called FSMon (and FSMonTest), added by Massimo Del Fedele.
|
Cool, totally missed that Thanks for noticing us Sender 
Honza
|
|
|
|
|
Goto Forum:
Current Time: Tue May 06 02:35:44 CEST 2025
Total time taken to generate the page: 0.00920 seconds
|