BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

How does FindFirst/FindNext react, if the directory-contents

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (VCL Components Usage)
View previous topic :: View next topic  
Author Message
Guest






PostPosted: Mon May 15, 2006 9:14 am    Post subject: How does FindFirst/FindNext react, if the directory-contents Reply with quote



How does FindFirst/FindNext react, if the directory-contents is
changed?

My guess is that it reads the complete directory (into an internal
structure like a list) when calling FindFirst() and FindNext() will
deliver the next contents, but I can't get any information about that

The problem which arises when using FindFirst/Next was that inside the
FindFirst/Next loop it might occur that the deletion of an already
delivered / the current / a not yet delivered file is necessary. So I
was quite irritated when having deleted a file some FindNext-s later
this filename was delivered. (So I had to insert a FileExists()-check
to make sure, that the delivered file really does exist).

If my guess is correct, I can handle these side-effects with
FileExists() (and this should be sufficent). If not, how is this done
and might there be other side-effects to keep an eye on.

Is FindFirst/FindNext just a wrapper around findrist/findnext (i.e. do
findrfirst/next behave the same way as FindFirst/Next)?

Thanks a lot,

Michael
Back to top
Pete
Guest





PostPosted: Mon May 15, 2006 10:14 pm    Post subject: Re: How does FindFirst/FindNext react, if the directory-cont Reply with quote



MR wrote:
Quote:
How does FindFirst/FindNext react, if the directory-contents is
changed?

Ummm, you can get most of the answers to your questions with a modest
amount of experimentation. Using FileExists() only covers half your
problem, does not help for newly created files.

You could use Windows API calls FindFirstChangeNotification() and
ReadDirectoryChangesW() to watch for changes as they happen.

If you'd rather stay within the VCL then you could use FindFirst() and
its pals to build a complete list of files to be processed, handle
those, then at the end of your processing build a new list and look for
added files. Repeat until no changes.

-- Pete
Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (VCL Components Usage) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.