[alt.sources] Relative path to Absolute Path

pt@geovision.gvc.com (Paul Tomblin) (04/24/91)

pt@geovision.gvc.com (Paul Tomblin) writes:

>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.... 
pt@geovision.gvc.com or {cognos,uunet}!geovision!pt      ! Me neither.

ksh@ai.mit.edu (K. Shane Hartman) (04/25/91)

In article <1515@geovision.gvc.com> pt@geovision.gvc.com (Paul Tomblin) writes:

   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