Date: Sun, 31 Aug 1997 19:13:06 +0300 (IDT) From: Eli Zaretskii To: Thomas Demmer 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: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Precedence: bulk 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.