Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » Community » Newbie corner » Need help with algorythm
Need help with algorythm [message #40455] Sun, 04 August 2013 19:02 Go to next message
lectus is currently offline  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 Go to previous messageGo to next message
dolik.rce is currently offline  dolik.rce
Messages: 1758
Registered: August 2008
Location: Czech Republic
Senior Contributor

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++ Wink

Best regards,
Honza
Re: Need help with algorythm [message #40457 is a reply to message #40456] Sun, 04 August 2013 21:41 Go to previous messageGo to next message
Sender Ghost is currently offline  Sender Ghost
Messages: 288
Registered: November 2008
Experienced Member
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.

[Updated on: Sun, 04 August 2013 22:28]

Report message to a moderator

Re: Need help with algorythm [message #40459 is a reply to message #40457] Mon, 05 August 2013 06:54 Go to previous messageGo to next message
dolik.rce is currently offline  dolik.rce
Messages: 1758
Registered: August 2008
Location: Czech Republic
Senior Contributor

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 Smile Thanks for noticing us Sender Wink

Honza
Re: Need help with algorythm [message #40512 is a reply to message #40459] Thu, 08 August 2013 14:22 Go to previous messageGo to next message
mdelfede is currently offline  mdelfede
Messages: 1259
Registered: September 2007
Senior Contributor
Yep, I forgot to put in Bazaar packages list Wink
Re: Need help with algorythm [message #40525 is a reply to message #40512] Fri, 09 August 2013 08:27 Go to previous message
koldo is currently offline  koldo
Messages: 3033
Registered: August 2008
Ultimate Member
Just do it! Wink

Best regards
IƱaki
Previous Topic: Does someone have an example of drag and drop for GridCtrl?
Next Topic: Did something change in Controls4U? (Only drawing in Design mode)
Goto Forum:
  


Current Time: Tue Nov 19 19:53:16 CET 2019

Total time taken to generate the page: 0.02738 seconds