comp.lang.ada
 help / color / mirror / Atom feed
From: lr@quux.apana.org.au (Lachlan Roche)
Subject: Re: Filename comparison ... HELP NEEDED!
Date: 12 Dec 1994 07:50:57 GMT
Date: 1994-12-12T07:50:57+00:00	[thread overview]
Message-ID: <LR.94Dec12175057@quux.apana.org.au> (raw)
In-Reply-To: jewell@cci.de's message of 2 Dec 1994 11:40:33 GMT


In article <3bn13h$jmo@speedy.cci.de> jewell@cci.de (Nigel Jewell) writes:
>Does anybody know of an good solution to seeing if two filenames given actually
>point at the same file in the file system?  (Probably a solution in C).

The canonical method is inode comparison. If the inodes are the same, its
the same file.

eg.

/* do these two names refer to a single file? */
int is_alias( char *name1, char *name2 )
{
  struct stat stat1, stat1;

  stat( name1, &stat1 )
  stat( name2, &stat2 )

  return stat1.st_ino == stat2.st_ino;
}

--
Lachlan Roche	... in Brisbane, Australia ...		lr@quux.apana.org.au



  parent reply	other threads:[~1994-12-12  7:50 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1994-12-02 11:40 Filename comparison ... HELP NEEDED! Nigel Jewell
1994-12-02 15:14 ` Frank Pilhofer
1994-12-02 16:53 ` Tanmoy Bhattacharya
1994-12-05  8:00   ` Nigel Jewell
1994-12-12  7:50 ` Lachlan Roche [this message]
1994-12-12 15:28   ` David Emery
  -- strict thread matches above, loose matches on Subject: below --
1994-12-05 18:27 Bennett, Chip (KTR) ~U
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox