comp.lang.ada
 help / color / mirror / Atom feed
From: emery@goldfinger.mitre.org (David Emery)
Subject: Re: Filename comparison ... HELP NEEDED!
Date: 12 Dec 94 15:28:33
Date: 1994-12-12T15:28:33+00:00	[thread overview]
Message-ID: <EMERY.94Dec12152833@goldfinger.mitre.org> (raw)
In-Reply-To: lr@quux.apana.org.au's message of 12 Dec 1994 07:50:57 GMT

Sorry, comparing inodes is insufficient.  Inodes are unique on a given
device.  Two files, on two separate devices, may have the same inode
number.  Thus, the C return should be 

	return ((stat1.st_ino == stat2.st_ino) 
		&& (stat1.st_dev == stat2.st_dev));

Implemented in POSIX/Ada, the same function would be

with POSIX, POSIX_File_Status;
function same_file (f1, f2 : POSIX.pathname)
    return boolean
is
  function "=" (l, r : POSIX_FIle_Status.File_ID) 
      return boolean renames POSIX_File_Status."=";
  function "=" (l, r : POSIX_FIle_Status.Device_ID) 
      return boolean renames POSIX_File_Status."=";
  status1, status2 : POSIX_File_Status.status;
begin
  status1 := POSIX_File_Status.Get_File_Status (f1);
  status2 := POSIX_File_Status.Get_File_Status (f2);
  return ((POSIX_File_Status.Device_Id_Of (status1) 
	   = POSIX_File_Status.Device_ID_Of (Status2))
          and then	-- no need to check file_ID if Device_IDs
			-- are different.
	  (POSIX_File_Status.File_Id_Of (status1) 
	   = POSIX_File_Status.File_ID_Of (Status2))
	 );
end same_file;
				dave

p.s.  Does anyone know if device numbers are 'unique' for NFS-mounted
file systems?
--
--The preceeding opinions do not necessarily reflect the opinions of
--The MITRE Corporation or its sponsors. 
-- "A good plan violently executed -NOW- is better than a perfect plan
--  next week"                                      George Patton
-- "Any damn fool can write a plan.  It's the execution that gets you
--  all screwed up"                              James Hollingsworth
-------------------------------------------------------------------------



  reply	other threads:[~1994-12-12 15:28 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
1994-12-12 15:28   ` David Emery [this message]
  -- 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