You could use this scheme to periodically check directory for new files don’f forget to wait a little after you find file before you open it to make sure file is completely written.
Of course you’d have to keep list of already opened files to compare to, OR
for example, you could convert vector to map and mark already opened files.
Thank you very much for the explanation.
My problem is actually with the second loop that you have mentioned. The code that you have shown works fine, but I could not get it working inside another loop. The simplest form of what I am trying is the following.
void *thedir = gSystem->OpenDirectory(dir.c_str());
const char *direntry;
int currentIndex=0;
while(!stop){
while ((direntry = gSystem->GetDirEntry(thedir))) {
cout<<direntry<<endl;
}
gSystem->Sleep(5000);
}
Could you please let me know if this is similar to what you have mentioned?
Quite simple and elegant thing to do for you would be to use TTimer class to have your CheckDirectoryAndDrawIfNew() called every so often. It’s interface pretty self explanatory.