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 » Developing U++ » UppHub » Added FSMon - FileSystem Monitor class
Added FSMon - FileSystem Monitor class [message #36206] Sat, 12 May 2012 09:32 Go to previous message
mdelfede is currently offline  mdelfede
Messages: 1307
Registered: September 2007
Ultimate Contributor
Hi,

I dropped a small class, FSMon, along with its demo FSMonTest, which allows monitoring a folder and its sub-folders for file changes.
Usage is quite simple :

FSMon fsMon;

// this will add a monitored path
fsMon.Add(APathToMonitor);

// this will remove it
fsMon.Remove(AMonitoredPath);



Catch of events can be done by polling

while(true)
{
    if(fsMon.HasChanges())
    {
        Vector<FSMon::Info> info = fsMon.GetChanged();
        for(int i = 0; i < info.GetCount(); i++)
            DoSomething(info[i].path, info[i].newPath, info[i].flags);
    }
    else
        Sleep(100);
}


or event driven with a callback :
void eventHandler(void)
{
    Vector<FSMon::Info> info = fsMon.GetChanged();
    ......
}

fsMon.EventHandler = THISBACK(eventHandler);


Beware, for the event-driven the behaviour is different if runnini inside a GUI app or a NON-GUI app :
for GUI apps, the call is done through a PostCallback, so runs in main thread
for NON GUI apps, the call is direct, so runs in FSMon monitoring thread, which is not good for lengty operations.

So, for NON-GUI apps it's better to use a separate thread and polling.

FSMon can catch file/folders creation, deletion and renaming, along with attribute changes. See flags in FSMon.h and the sample FSMonDemo for details.

Ciao

Max
 
Read Message
Read Message
Read Message
Read Message
Previous Topic: StaticImage enhancement
Next Topic: Added Scgi class to replace Web/ScgiServer
Goto Forum:
  


Current Time: Thu Apr 18 06:00:31 CEST 2024

Total time taken to generate the page: 0.01976 seconds