[Mono-list] Determining the full name of the file

Jaroslaw Kowalski jarek@atm.com.pl
Sat, 3 Aug 2002 13:09:28 +0200


Hi!

I want to hack a bit on ".config" files, but I need an robust method to get
the full file path given a (possibly relative) file name.

I came up with the following idea:

If the file is absolute (starts with a slash on Unix, slash, backslash,
drive letter or double backslash on Windows) - just normalize it.

If the file is relative - concatenate the result of getcwd() + "/" + file
name and normalize the result.

By normalization I mean optimizing away /../, /./ and converting multiple
(back)slashes into one.

Before I stard coding I wanted to ask you, if you know about any good (not
realpath() as it isn't safe) library function to do this? Also, I don't want
to resolve symlinks as realpath() does.

Jarek