apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "David Reid" <dr...@jetnet.co.uk>
Subject Re: apr_realpath
Date Sun, 04 Mar 2001 15:17:02 GMT
This all looks good, but I wonder if also having a simple function along the
lines of unix's realpath wouldn't be a useful addition as well.  I'd
envisage soemthing whereby you just pass a path and it returns the full path
using the current directory as a starting point.  I can see room for both as
they do slightly different things.

if I have just a path relative to where I am now ... use apr_realpath
I want a full path based on a location plus a relative path ... use

In some ways I'm not sure we'd ever use apr_realpath in apache, but other
projects may well find it useful.


----- Original Message -----
From: "William A. Rowe, Jr." <admin@rowe-clan.net>
To: "David Reid" <dreid@jetnet.co.uk>; "APR Development List"
Sent: Sunday, March 04, 2001 6:09 AM
Subject: Re: apr_realpath

> Here's what I envision...
> #define APR_DM_TRUECASE       0x01
> #define APR_DM_NOTABOVEROOT   0x02
> #define APR_DM_NOTRELATIVE    0x04
> #define APR_DM_NOTABSOLUTE    0x08
> #define APR_DM_CANONICAL      0x10
> apr_status_t apr_dir_merge(char *newpath, const char *rootpath, const char
>                            apr_int32_t flags, apr_pool_t *p)
> Where rootpath may be null, but only newpath elements are proper cased.
> Since getting the true case is a slow operation, and we can trust rootpath
> doesn't matter (true name only instead of true path) or was already
truecased, we
> are halfway to the finish line :-)  Also, don't assume root path is
absolute.  It
> could simply be 'foo' and addpath could be 'bar', resulting in foo/bar.
Or in that
> same example, addpath could be '../../bar', resulting in '../bar'
(relative to foo).
> NOTABOVEROOT means addpath can't be '../bar' [technically, it could.
Should we allow
> the case where root /foo/bar + '../bar' is not above root?]  Note that
> precludes returning a relative name that is '../anything', since that is
above whatever
> root path it would be concatinated to, later.
> NOTABSOLUTE and NOTRELATIVE mean just what they suggest.  Note that if the
> is not absolute, the name is never truecased.
> Dirmerge will resolve all '..', '.', '//' and other pathing issues into a
> form, iff CANONICAL is flagged.  If not, a slash will be added iff the
rootpath isn't
> slash terminated, e.g. 'foo' 'bar' will become 'foo/bar', but 'test/'
'path' won't
> ever inherit an extra slash, ever if CANONICAL is not specified.
> Note especially, the rootpath is presumed to have been processed through
> appropriate TRUECASE and CANONICAL filters, and _only_ the addpath is
> by those rules.  We are essensially asking, take this root, fix up this
> and give us the new (more) complete path.
> Doing all of these operations as single-pass should be quite quick.  Can
we all
> live with this API?  Other ideas, suggestions or pointers to my
> Sorry I couldn't wrap this today (and would like to read the feedback to
> proposal.)  It's as fast as I can picture, and should work for 98% of the
> Comments are welcome.
> Bill
> ----- Original Message -----
> From: "David Reid" <dreid@jetnet.co.uk>
> To: "APR Development List" <dev@apr.apache.org>
> Sent: Saturday, March 03, 2001 9:55 AM
> Subject: apr_realpath
> > Did we ever get a point of agreeing if we wanted to add apr_realpath?  I
> > seem to have deleted the emails concerning it but ISTR that there was a
> > patch?
> >
> > david
> >
> >

View raw message