Relative path to Absolute Path

Relative path to Absolute Path

Post by Paul Tombl » Thu, 25 Apr 1991 03:32:15




>Does anybody have a routine to go from a relative file (or directory)  path to
>an absolute (rooted) one?  I need one for both unix and vms.  I need to be
>able to go from relative to absolute in the following cases:

Although I got absolutely zero response to this request, I did find an
answer.  With the error checking turned off, what I ended up doing was
approximately this:

        chdir(new_dir);
        getcwd(new_dir, MAX_PATH_LEN);

It works beatifully, on both VMS and unix.  (And probably DOS, but
I wouldn't bet my life on it.)

--
Paul Tomblin, Department of Redundancy Department.       ! My employer does
Two roads diverged in a wood, and I/ I took the one less ! not stand by my
travelled by/ And that is why I'm lost, dammit...        ! opinions....

 
 
 

Relative path to Absolute Path

Post by K. Shane Hartm » Fri, 26 Apr 1991 12:22:26


   Although I got absolutely zero response to this request, I did find an
   answer.  With the error checking turned off, what I ended up doing was
   approximately this:

           chdir(new_dir);
           getcwd(new_dir, MAX_PATH_LEN);

   It works beatifully, on both VMS and unix.  (And probably DOS, but
   I wouldn't bet my life on it.)

Works fine in DOS too.  The only wrinkle I add to it is error checking
for nonexistent path and preserve the original path.

Shane Hartman

 
 
 

1. Relative path to Absolute path

I'm looking for a C algorithm to convert relative paths to an absolute
path.

For instance, I want to resolve "/usr/bin/X11/../ls" into "/usr/bin/ls."
But I would also like to generally clean up a path as well; eg.
"/usr/bin//ls" to "/usr/bin/ls," and so on.

Years ago I saw an algorithm to do this, posted here, but I have since
lost the darn thing.

Thanks for any ideas,
RH

2. sfio for linux ?

3. Symbolic Links - Absolute Paths to Relative Paths

4. Trumpet Winsock 2.0B PPP and Solaris 2.4 x86 PPP

5. C: get absolute path to a file from relative path

6. telnet hangs? Slackware 2.0

7. Add an absolute path prefix only to relative paths

8. 3COM 3C509B PNP Problem

9. How to convert a relative path into an absolute one?

10. tarring absolute paths for relative untar

11. Make relative tar path absolute at extraction

12. finding absolute or relative path?

13. Relative / absolute paths and symlinks