From 2674025970140820134
X-Google-Language: ENGLISH,ASCII
X-Google-Thread: f78e5,8229fd0d89d55aa7
X-Google-Attributes: gidf78e5,public
From: jkanze@otelo.ibmmail.com
Subject: Re: Access to fstat for an fstream
Date: 1998/04/08
Message-ID: <6ggbfh$dmh$1@nnrp1.dejanews.com>#1/1
X-Deja-AN: 342160397
Approved: Fergus Henderson <fjh@cs.mu.oz.au>
References: <6gb6t9$4ni@bcarh8ab.bnr.ca> <6gddui$a5p$1@nnrp1.dejanews.com> <6ge34e$672@bcarh8ab.bnr.ca>
X-Original-Date: Wed, 08 Apr 1998 12:17:37 -0600
X-Authentication-Warning: philabs-gw.philabs.research.philips.com: smap set sender to <news@dejanews.com> using -f
X-Http-User-Agent: Mozilla/4.03 [de] (WinNT; I)
Organization: Deja News - The Leader in Internet Discussion
X-Article-Creation-Date: Wed Apr 08 17:17:37 1998 GMT
X-Auth: PGPMoose V1.1 PGP comp.std.c++ iQBFAgUANSvLdeEDnX0m9pzZAQF2rgF9HAl/sPYKcQuuBtc+n2ODLMr5n19xEQi4 zGZ6B5icIeQJYrqae6yCA90DFG5/ocQL =ghlz
Newsgroups: comp.std.c++


In article <6ge34e$672@bcarh8ab.bnr.ca>,
  "Jim Cobban" <jcobban@nortel.ca> wrote:
>
> In article <6gddui$a5p$1@nnrp1.dejanews.com>,
>  <jkanze@otelo.ibmmail.com> wrote:
> >Can you give a reasonably portable definition for what is supported by
> >"struct stat"?
>
> The contents and definition of struct stat are defined in both POSIX and
> X/Open.

Which are both standards for Unix, or Unix-like operating systems.
Not all C++ runs on such systems.

> I haven't checked, but it may also be in ANSI C.

It's not.  ANSI C does not require an int as file descripter.  Many
systems do not use an int (or any basic type) as file descripter.

> Note that these
> standards do not describe UNIX, per se, but rather an abstract system
> interface and set of commands which provide a minimal common subset of
> functions which can be implemented on a wide range of platforms.

The system that they describe is the one commonly called UNIX.  In the
case of Posix, the name of the standard is not UNIX uniquely for
trademark reasons.

UNIX, in almost any of its variants, can be implemented on a wide range
of platforms.  The fact that UNIX can be implemented on a platform,
however, is not sufficient justification for insisting that C/C++ only
be available under a UNIX like OS.

> stat is
> available, for example, on operating systems as diverse as Windows 95 and
> IBM's mainframe OS/390 (formerly known as MVS).

Well, Windows derives ultimately from MS-DOS, which in version 2.0
adopted a large part of the UNIX IO interface.  (Microsoft was
actually a UNIX distributor back then.)

    [Details of the stat structure deleted...]

My point is only that in standard C++, the only way to find the actual
size of a file is to open it in binary mode and read it, counting the
bytes.  I agree that there can be more efficient ways on many OS's.
If I needed to know the size of a file, and depending on portability
constraints, I would use them.  On the other hand, I wouldn't present
them as part of C++ in comp.std.c++ (although when they are relatively
portable, as fstat is, I won't mind talking about them in other C++
forums).

--
James Kanze    +33 (0)1 39 23 84 71    mailto: kanze@gabi-soft.fr
        +49 (0)69 66 45 33 10    mailto: jkanze@otelo.ibmmail.com
GABI Software, 22 rue Jacques-Lemercier, 78000 Versailles, France
Conseils en informatique orient�e objet --
              -- Beratung in objektorientierter Datenverarbeitung

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/   Now offering spam-free web-based newsreading
---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]



