I'm trying to write a method to monitor a directory for a file to be created. This file will have the extension .complete
. If it is not there, I want to wait for it to appear. When it does appear, I want to find extract the name of the file before the extension, delete the .complete
file, do some processing, and then go back to listening for a new .complete
file.
Here's what I have so far. I think I just need help extracting the name of the file, assuming I did the wildcard's correctly.
while(1) {
if (!boost::filesystem::exists("/var/test/*.complete")) {
cout << ".complete file does not exist" << endl;
}
else {
//extract name of .complete file minus extension
//do my processing
system("rm *.complete");
}
}