Ethereal-dev: Re: [Ethereal-dev] file_exists() returning the oposite?

Note: This archive is from the project's previous web site, ethereal.com. This list is no longer active.

Date: Wed, 8 Feb 2006 02:16:17 +0100
On 2/8/06, Guy Harris <gharris@xxxxxxxxx> wrote:
> LEGO wrote:
> > I realy do not know if file_exists() from epan/filesystem.c works on
> > windows but I've seen it does not on my mac and AFAIK it should not
> > work on *NIX in general.
>
>     ...
>
> >   /*
> >    * This is a bit tricky on win32. The st_ino field is documented as:
> >    * "The inode, and therefore st_ino, has no meaning in the FAT, ..."
> >    * but it *is* set to zero if stat() returns without an error,
> >    * so this is working, but maybe not quite the way expected. ULFL
> >    */
> >    file_stat.st_ino = 1;   /* this will make things work if an error
> > occured */
> >    eth_stat(fname, &file_stat);
>
> Is there some reason why we don't simply check whether eth_stat() returns
> -1 or not?  On UN*X, to test whether a file exists, you would probably try
> to stat it and, if the stat fails with ENOENT, say it doesn't exist,
> otherwise (i.e., if it succeeds *or* if it fails and sets errno to
> something other than ENOENT) say it does (even if we don't have permission
> to look for it).

That's what I did.

> Would that work on Windows as well?
>
> (We should also be checking for eth_stat() succeeding or failing in
> files_equal() on UN*X, rather than doing the hack with the two st_ino
> values.)

As far as the two files live on the same filesystem that is true, we
are missing the  check for equal device numbers.

--
This information is top security. When you have read it, destroy yourself.
-- Marshall McLuhan