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
Re: Need help with algorythm [message #40456 is a reply to message #40455] Sun, 04 August 2013 19:57 Go to previous messageGo to previous message
dolik.rce is currently offline  dolik.rce
Messages: 1789
Registered: August 2008
Location: Czech Republic
Ultimate 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
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
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: Fri Apr 26 10:57:55 CEST 2024

Total time taken to generate the page: 0.09724 seconds