Article View: borland.public.cppbuilder.nativeapi
Article #14487Re: Directory in use after FindFirstFile ?!
From: Andrue Cope
Date: Tue, 12 Aug 2003 11:59
Date: Tue, 12 Aug 2003 11:59
36 lines
2151 bytes
2151 bytes
ScOe,
> if (filehandle)
> FindClose (filehandle) ;
>
This would be better written as:
if( fileHandle!=INVALID_HANDLE_VALUE )
FindClose( fileHandle );
.and you might as well remove the earlier call to FindClose().
I'll also suggest that you should not recurse in this way. The
problems with scanning a directory as soon as you find it are:
* Files can be processed in a somewhat haphazard way instead of
being grouped with their siblings.
* It can result in multiple file searches being active at the same
time which some OSes have a problem with.
A better solution is to simply note the directories as you find them
and deal with them only after directory search is complete IOW:
1.Search directory
Process files, make a note of subdirectories
2.Process each of the noted subdirectories in turn.
But I'd also have to ask if you are using chdir() in your app.? If
you are then this could be the problem. My recommendation to /anyone/
is that they never use this (IMO) heinous function (in any of its
guises).
--
Andrue Cope
[Bicester, UK]
Technical Details
Message-ID:
<VA.00001ea0.00e82f60@email.address.sorry>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!sn-xit-03!sn-xit-01!sn-xit-09!supernews.com!news.maxwell.syr.edu!newsfeed.wirehub.nl!news.kweb.on.ca!KWeb!newsgroups.borland.com!not-for-mailReferences:
<3f38c3b7@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10cc67,7baaff1b6531e4d0 X-Google-Attributes: gid10cc67,public X-Google-ArrivalTime: 2003-08-12 05:04:14 PST Date: Tue, 12 Aug 2003 12:59:03 +0100 Newsgroups: borland.public.cppbuilder.nativeapi Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Newsreader: Virtual Access by Atlantic Coast PLC, http://www.atlantic-coast.com/va Message-ID: <VA.00001ea0.00e82f60@email.address.sorry> Subject: Re: Directory in use after FindFirstFile ?! From: Andrue Cope <not.a.valid@email.address.sorry> Reply-To: not.a.valid@email.address.sorry References: <3f38c3b7@newsgroups.borland.com> NNTP-Posting-Host: 217.207.223.34 X-Trace: newsgroups.borland.com 1060689612 217.207.223.34 (12 Aug 2003 05:00:12 -0700) Lines: 37 Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!sn-xit-03!sn-xit-01!sn-xit-09!supernews.com!news.maxwell.syr.edu!newsfeed.wirehub.nl!news.kweb.on.ca!KWeb!newsgroups.borland.com!not-for-mail