Article View: borland.public.cppbuilder.nativeapi
Article #12051Re: Tracking the number of open files
From: Paul Dowd
Date: Wed, 31 Dec 2003 15:28
Date: Wed, 31 Dec 2003 15:28
61 lines
2529 bytes
2529 bytes
Ok, many thanks
Paul
"Hans Galema" <dontusethis@dontusethis.nl> wrote in message
news:3fe9b1d0@newsgroups.borland.com...
> 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:
<3ff2edb0@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!fu-berlin.de!news-FFM2.ecrc.net!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> <3fe9b1d0@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-31 08:10:07 PST Reply-To: "Paul Dowd" <pauldowd@seisqc.freeserve.co.uk> From: "Paul Dowd" <pauldowd@seisqc.freeserve.co.uk> Newsgroups: borland.public.cppbuilder.nativeapi References: <3fda0259@newsgroups.borland.com> <3fda27b1$1@newsgroups.borland.com> <3fe96c6b@newsgroups.borland.com> <3fe9b1d0@newsgroups.borland.com> Subject: Re: Tracking the number of open files Date: Wed, 31 Dec 2003 15:28:02 -0000 Lines: 63 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 NNTP-Posting-Host: 81.105.52.175 Message-ID: <3ff2edb0@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1072885168 81.105.52.175 (31 Dec 2003 07:39:28 -0700) Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!fu-berlin.de!news-FFM2.ecrc.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail