[TUHS] Also, relative to absolute pathnames?

Alan Coopersmith via TUHS tuhs at tuhs.org
Fri Jun 26 07:51:33 AEST 2026


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

-- 
         -Alan Coopersmith-                 alan.coopersmith at oracle.com
          Oracle Solaris Engineering - https://blogs.oracle.com/solaris


More information about the TUHS mailing list