[TUHS] Also, relative to absolute pathnames?

Steffen Nurpmeso via TUHS tuhs at tuhs.org
Fri Jun 26 08:49:46 AEST 2026


Alan Coopersmith via TUHS wrote in
 <227fc343-8050-4d7e-aa9b-0c3533507c3f at oracle.com>:
 |On 6/25/26 14:38, Warren Toomey via TUHS wrote:
 |> On a related note, is there a C function (or do you have source code) to
 |> convert a relative pathname to an absolute one?
 |> 
 |> e.g.
 |> 
 |> // Given the current working directory and
 |> // a pathname, return an absolute pathname
 |> // with all '..' removed.
 |> char *relpath_to_abs(char *cwd, char *path);
 |> 
 |> Before I try to write one I thought I'd ask around :-)
 |
 |In modern POSIX, including Unix98 & later, realpath():
 |https://pubs.opengroup.org/onlinepubs/9799919799/functions/realpath.html

But avoid calling it on /dev/null on (certain?) Solaris, they give
you eg "[/devices/pseudo/]mm at 0:null", and that could be the tip of
the iceberg only.

--steffen
|
|Der Kragenbaer,                The moon bear,
|der holt sich munter           he cheerfully and one by one
|einen nach dem anderen runter  wa.ks himself off
|(By Robert Gernhardt)


More information about the TUHS mailing list