www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/1999/05/14/22:38:58

Date: Sat, 15 May 1999 04:38:47 +0200
From: Frank Heckenbach <frank AT tim DOT gerwinski DOT de>
Message-Id: <532C6F74.19990515043847.FOO-45EF.frank@goedel.fjf.gnu.de>
X-Mailer: smtphack 0.3.3 by Jan Andres
To: eliz AT is DOT elta DOT co DOT il, djgpp-workers AT delorie DOT com
Subject: Re: realpath()
Reply-To: djgpp-workers AT delorie DOT com

> > do you plan to support the realpath() function?
> 
> Nobody asked for it until now (personally, I didn't even know such a
> function existed on Unix platforms).

It seems to come from the BSD variants...

> It should be easy to add a simple wrapper around _fixpath.  Volunteers
> are welcome ;-)

I don't have enough knowledge of Dos and DJGPP to do it myself. (I
develop on Linux, and compile my code also for DJGPP for others who
need/want it.)

Anyway, what a realpath function would have to do is simply:

call _fixpath (with the same 2 arguments that it takes)
check if the resulting path exists
if so, return it (i.e., the second parameter resolved_path)
otherwise:
find the first component that does not exist
truncate resolved_path after that component
return NULL

In particular, I don't know how to check for existence of a path in
the best way. access could be used, I suppose, but since it's a bit
longish and calls _fixpath again, this might not be the best
solution, since it may be necessary to call it a number of times.
Perhaps it's better to extract the parts of access that do the real
work, but that seems to be low-level Dos stuff I'd rather not get
into...

Frank

-- 
Frank Heckenbach, frank AT fjf DOT gnu DOT de
http://fjf.gnu.de/
PGP and GPG keys: http://fjf.gnu.de/plan

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019