|
From: Per W. <pw...@ia...> - 2005-05-20 09:18:43
|
You mean the portability that have made M$ rename that function to
_fstat() - at the same time they renamed _mkdir(), _open(), _close(),
_read(), _write(), _chmod(), _access(), _chdir(), ...
For just quick-checking existence or read or write access, access() is the
nicest function - no structs and extra tests needed.
stat(), fstat(), lstat() are more powerful, but requires more work - extra
include files and a struct stat variable.
On the other hand. If the intention is to actually open and/or create the
file, there is normally no need to pre-check existence. The used open
command can handle it.
/Per W
On Fri, 20 May 2005, Gilles Crebassa wrote:
> Hello,
>
> with function "fstat" , you have possibility to
> receive size of file , owner ,.... and existence (+
> portability).
>
>
> Gilles
>
> --- Per Westermark <pw...@ia...> a =E9crit:
> > Have you looked at the access() function -
> > specifically there to check for
> > existence - or specific rights - for a file.
> >
> > /Per W
> >
> > On Fri, 20 May 2005 A_B...@gm... wrote:
> >
> > > Well, it's a little bit unconventional, but I
> > check file existans in this way:
> > >
> > > if(FILE* f =3D fopen("file", "r")){
> > > fclose(f);
> > > // file exists
> > > ...
> > > }else{
> > > // file doesn't exist
> > > ...
> > > }
> > >
> > > What speaks against this method ???
> > >
> > > CU, Acki
|