comp.lang.ada
 help / color / mirror / Atom feed
From: jewell@cci.de (Nigel Jewell)
Subject: Filename comparison ... HELP NEEDED!
Date: 2 Dec 1994 11:40:33 GMT
Date: 1994-12-02T11:40:33+00:00	[thread overview]
Message-ID: <3bn13h$jmo@speedy.cci.de> (raw)

Hi,

I apologise if this is irrelevant to any groups posted to, but I want as many
ideas/solutions as possible

I have a _small_ problem with an application that I am trying to write on a UNIX
platform using both C and Ada.  

Basically a user selects a file to load.  This file may point to other files.
For example:

file1:
	$HOME/test/file2
	../file3

file2:
	../file3

file3:

Each of these is loaded recursively therefore when a reference to file3 is seen
the file3 is loaded and processed in the same way.  Therefore I need to be able 
to check if a file has already been loaded.  In this case file3 from both files
1 and 2.

Here is the problem.

What if a user uses $HOME/test/file2 in one file and ~/test/file2 in another
file, I cannot check that the file hasn't already been loaded.  One
solution suggested to me is to scan the filename for environment variables and
then substitute them in the string, using $HOME for the tilde.  This is not
a perfect solution though.  What if the user uses $HOME/test/dir1/../file3 and
$HOME/test/file3 ... do I have to go through and convert every filename checking
for:

environment variables: both $var and ${var}
username specification: e.g ~bob
the use of "." and ".."
links could also cause a problem.

this is a very long winded way of doing it ... and it may cause considerable
delays the more files there are to load.  Also I can't believe there isn't an
easier way than this!

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).

Any help would be REALLY REALLY appreciated.

Thanks in advance.

Nige.

PS. Replies by email would be prefered.

===============================================================================
E-mail : jewell@cci.de                               Tel. : +49 (0)5931-805-463
     Competence Center Informatik GmbH, Lohberg 10, 49716 Meppen. Germany.

**** Any views expressed may not be those shared by my employer, CCI GmbH. ****
===============================================================================





             reply	other threads:[~1994-12-02 11:40 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1994-12-02 11:40 Nigel Jewell [this message]
1994-12-02 15:14 ` Filename comparison ... HELP NEEDED! 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
  -- 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