Directory check for new files

L

Lorn

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.

Best regards,
Lorn Davies
 
P

Phlip

Lorn said:
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.

That is platform-specific, so other newsgroups are better qualified to
answer it.

You probably want the Win32 function FindFirstChangeNotification(). Google
for that, to learn what forums know more about it than ours.
 
K

Kai-Uwe Bux

Lorn said:
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.


Best

Kai-Uwe Bux
 
P

Phlip

Kai-Uwe Bux said:
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.
 
K

Kai-Uwe Bux

Phlip said:
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
 
L

Lorn

Just wanted to thank everybody for their input and suggestions. I'll
try and find another newsgroup where it's more on topic. Sorry about
that.

Lorn
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top