|
Home > Archive > Unix Programming > May 2005 > resolving file names
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
resolving file names
|
|
| Fred L. Kleinschmidt 2005-05-02, 5:56 pm |
| Given two file names ( for example, "/a/b/c/d" and "../xxx" ), what is
the easiest way to determine whether they resolve to the exact same
file. I actually want to do this from a C program; can this be done
with something like stat() and inode()?
--
Fred L. Kleinschmidt
Boeing Associate Technical Fellow
Technical Architect, Common User Interface Services
M/S 2R-94 (206)544-5225
| |
| Martijn Lievaart 2005-05-02, 5:56 pm |
| On Mon, 02 May 2005 20:29:54 +0000, Fred L. Kleinschmidt wrote:
> Given two file names ( for example, "/a/b/c/d" and "../xxx" ), what is
> the easiest way to determine whether they resolve to the exact same
> file. I actually want to do this from a C program; can this be done
> with something like stat() and inode()?
Almost, use both the st_dev and st_inode fields. Note that stat will
resolve softlinks and using the inode will resolve hardlinks. Most of the
time this is exactly what you want.
BTW, comp.unix.programmer is over there ================> :-)
M4
--
Ah, the beauty of OSS. Hundreds of volunteers worldwide volunteering
their time inventing and implementing new, exciting ways for software
to suck. -- Toni Lassila in the Monastry
|
|
|
|
|