Phlip wrote:
Kai-Uwe Bux wrote:
Lorn wrote:
> I'm trying to come up with some code that will continually scan a
> directory for new files and read the name of the most recent file. Does
> anyone have some suggestions on how this could be accomplished? Any
> help would be greatly appreciated.
Standard C++ does not even known that some operating systems actually
know about directories. Thus, what you want is platform specific. That
said, you might want to look into the Boost Filesystem Library. It has
a directory_iterator that allows you to traverse a directory.
Agreed this is off-topic, but the OP is asking for an asynchronous trigger
when a folder changes.
A windows Explorer does this. When another process creates or deletes a
file, the folder view updates in realtime.
I'm not sure, but I suspect the Boost Filesystem Library won't do that if
it limits the library's portability.
True. I was thinking of a somewhat simpler solution: just maintain a
sorted list of file-names from your last scan of the directory, regularly
rescan and find the new files. Then update your list. More nifty solutions,
of course, like having the OS notify you when the directory changes, are
highly non-portable, and I agree that Boost would probably not go there.
Best
Kai-Uwe Bux