Article View: borland.public.cppbuilder.nativeapi
Article #12170Re: Tracking the number of open files
From: Hans Galema
Date: Wed, 24 Dec 2003 15:37
Date: Wed, 24 Dec 2003 15:37
54 lines
2317 bytes
2317 bytes
Paul Dowd wrote:
> I use fopen() when wanting to read/write text and open() for binary. I know
> this is not very eloquent or consistent but thats the legacy of my long
> learning curve! Do both these methods not count towards the number of open
> files limit?
You can test that for yourself with:
void __fastcall TForm1::fopenButtonClick(TObject *Sender)
{
Memo1->Clear();
int filenr = 0;
Memo1->Lines->Add ( "FOPEN_MAX: " + IntToStr ( FOPEN_MAX ) );
while ( ++ filenr <= maxwanted )
{
char path [MAXPATH+2];
sprintf ( path, "fopen.%d.txt", filenr );
if ( ! fopen ( path, "wb" ) )
break;
Memo1->Lines->Add ( path );
}
}
Memo1->Clear();
Memo1->Lines->Add ( "FOPEN_MAX: " + IntToStr ( FOPEN_MAX ) );
int filenr = 0;
while ( ++ filenr <= maxwanted )
{
char path [MAXPATH+2];
sprintf ( path, "open.%d.txt", filenr );
int fd = open( path, // io.h
O_CREAT | O_TRUNC | O_RDWR |O_BINARY, S_IREAD | S_IWRITE );
if ( fd < 1 )
break;
Memo1->Lines->Add ( path );
}
> Which do you recommend? - I suppose I should stick to open() ??
Hans.
Technical Details
Message-ID:
<3fe9b1d0@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<3fda0259@newsgroups.borland.com> <3fda27b1$1@newsgroups.borland.com> <3fe96c6b@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10cc67,5c04324033f7eb51 X-Google-Attributes: gid10cc67,public X-Google-ArrivalTime: 2003-12-24 07:39:51 PST Date: Wed, 24 Dec 2003 16:37:49 +0100 From: Hans Galema <dontusethis@dontusethis.nl> User-Agent: Mozilla/5.0 (Windows; U; Win98; en-US; rv:1.6b) Gecko/20031208 X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: borland.public.cppbuilder.nativeapi Subject: Re: Tracking the number of open files References: <3fda0259@newsgroups.borland.com> <3fda27b1$1@newsgroups.borland.com> <3fe96c6b@newsgroups.borland.com> In-Reply-To: <3fe96c6b@newsgroups.borland.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 129.125.108.11 Message-ID: <3fe9b1d0@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1072280016 129.125.108.11 (24 Dec 2003 07:33:36 -0700) Lines: 54 Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail