delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/08/31/12:15:52

Date: Sun, 31 Aug 1997 19:13:06 +0300 (IDT)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
To: Thomas Demmer <demmer AT LSTM DOT Ruhr-UNI-Bochum DOT De>
cc: djgpp AT delorie DOT com, IBEC23 AT cc DOT uab DOT es
Subject: Re: How coould I know if two files are the same?
In-Reply-To: <34068AA4.22A0D53E@LSTM.Ruhr-UNI-Bochum.De>
Message-ID: <Pine.SUN.3.91.970831190908.17131B-100000@is>
MIME-Version: 1.0

On Fri, 29 Aug 1997, Thomas Demmer wrote:

> Eli Zaretskii wrote:
>
> > Another way would be to call `stat' on both files and compare the
> > st_dev and st_ino members of struct stat: if both of them are
> > identical, the two names refer to the same file.
>
> I think this is not correct:
>  stat() invents inodes for networked drives, i.e. it
>  counts upwards from 65536. It remembers which filenames it has 
>  seen before, so that two calls to stat() with the identical
>  name yields identical results. In the example above, however, 
>  the names are not identical. 

`stat' remembers the name as it was returned by `_truename', otherwise
even "m:foo" and "m:/dir/subdir/foo" would not yield the same inode. 
Since `_truename' is supposed to return UNCs in the case of networked 
drives, `stat' should indeed work as I described.

> What should work is something like
> 
>   _fixpath(fn1, fixed_fn1);
>   _fixpath(fn2, fixed_fn2);
>   _truename(fixed_fn1,canon_path1);
>   _truename(fixed_fn2,canon_path2);

`_truename' doesn't need `_fixpath' to be called before it, it does all 
the work itself.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright 2019   by DJ Delorie     Updated Jul 2019