views:

121

answers:

1

Hello. I was wondering if there is a portable way to determine if 2 different paths actually reference the same file.

I have read this thread but is Windows-specific.

AFAIK, fstream isn't suitable for the job.

+2  A: 

Boost.Filesystem, although I doubt it will go so far as to resolve hard links and junctions when giving you a canonical path.

wrang-wrang
The documentation suggest otherwise: http://www.opengroup.org/onlinepubs/000095399/basedefs/xbd_chap04.html#tag_04_11
Martin York
What's the connection between Boost.Filesystem and that documentation?
wrang-wrang
Symlinks, hard links, and junctions are one problem. And then there's also the problem of "short names" (think 8.3 alternate file names) in the Windows world.
Reuben
@wrang-wrang: stat here: http://www.boost.org/doc/libs/1_40_0/libs/filesystem/doc/reference.html then scroll down to the point "POSIX Pathname Resolution"
Martin York
Ok, thanks. So symlinks will be resolved when obtaining a canonical path, but probably not hardlink/junction?
wrang-wrang