From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=0.7 required=5.0 tests=BAYES_00,INVALID_DATE, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f891f,372ebe42676183e0,start X-Google-Attributes: gidf891f,public X-Google-Thread: f8c9b,372ebe42676183e0,start X-Google-Attributes: gidf8c9b,public X-Google-Thread: f72b0,372ebe42676183e0,start X-Google-Attributes: gidf72b0,public X-Google-Thread: 103376,372ebe42676183e0,start X-Google-Attributes: gid103376,public X-Google-Thread: 1012a6,372ebe42676183e0,start X-Google-Attributes: gid1012a6,public X-Google-Thread: fc89c,372ebe42676183e0,start X-Google-Attributes: gidfc89c,public X-Google-Thread: 1014db,372ebe42676183e0,start X-Google-Attributes: gid1014db,public X-Google-ArrivalTime: 1994-12-02 04:09:39 PST Path: bga.com!news.sprintlink.net!howland.reston.ans.net!Germany.EU.net!cci.de!news From: jewell@cci.de (Nigel Jewell) Newsgroups: comp.lang.ada,comp.lang.c,comp.lang.misc,comp.unix.programmer,comp.unix.questions,comp.unix.shell,comp.unix.misc Subject: Filename comparison ... HELP NEEDED! Date: 2 Dec 1994 11:40:33 GMT Organization: CCI GmbH, Germany. Distribution: world Message-ID: <3bn13h$jmo@speedy.cci.de> Reply-To: jewell@cci.de NNTP-Posting-Host: speedy.cci.de Keywords: filenames, C, Ada Xref: bga.com comp.lang.ada:8174 comp.lang.c:32973 comp.lang.misc:4291 comp.unix.programmer:9507 comp.unix.questions:17261 comp.unix.shell:7804 comp.unix.misc:5069 Date: 1994-12-02T11:40:33+00:00 List-Id: 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. **** ===============================================================================