apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "William A. Rowe, Jr." <wr...@rowe-clan.net>
Subject Re: apr_realpath
Date Wed, 14 Mar 2001 21:29:49 GMT
From: "Kevin Pilch-Bisson" <kevin@pilch-bisson.net>
Sent: Wednesday, March 14, 2001 3:08 PM


> > > Would there be a way to convert an incomplete path to a complete path?
> > > (change drive to c:, getpwd, append foo, in the above example)
> > 
> > That is what apr_filepath_merge does for you.  You can pass a partial root [/ or
d:]
> > apr_filepath_root over to apr_filepath_merge as the addpath (with a null root).
 That
> > will return a true root.  apr_filepath_root is as much to help apr_filepath_merge
> > (and any other app) break apart the root from a name, since the root is very platform
> > specific (moreso than any other part of this debate.)  Look at netware machine/sys:/
> > versus win32/os2, toss in unc names and unix remote volumes and ugh, what a mess.
> > 
> I believe you, I am just a little confused as to the process.  Say I do
> the following:
> 
> C:\mywork\subversion\ > svn commit C:foo
> 
> which eventually reaches the following code.
> 
> char added_path[][] = { "C:foo", NULL };
> (or should this be { "C:", "foo", NULL }; ?)
> char *newpath;
> apr_filepath_merge(&newpath, NULL, added_path, APR_FILEPATH_TRUEPATH, p);
> 
> What do I get back from apr_filepath_merge?  Or more to the point, how
> can I get C:\mywork\subversion\foo as newpath?

Simply, rootpath == NULL uses CWD, therefore c:\mywork\subversion.


char *newpath = "foo"
char **addpath = &newpath
char **newpath;

apr_filepath_merge(&newpath, NULL, addpath, APR_FILEPATH_TRUEPATH, p);

If foo exists, newpath == "c:\mywork\subversion\foo", and addpath += 4
(points to the trailing NULL of the string you passed).

If foo is not found, newpath == "c:\mywork\subversion\" and addpath didn't
change (the path wasn't found.

If you pass "foo/bar" as addpath, and foo exists, then ".../foo/" is retured
for newpath, and addpath += 4 (pointing at "bar") if bar was not found.

Of course, without APR_FILEPATH_TRUEPATH, the whole thing just returns, and
doesn't care if the path names are real.  With APR_FILEPATH_TRUECASE, those
parts that exist are returned with the correct case followed by the remaining
given path, since it also doesn't care if the files exist, only that the
names that exist are the proper case.  Both of these would set point addpath
to it's own trailing NULL.

The Q. remains, do we want char** addpath, or simply a char* with no feedback
of existing v.s. nonexisting path components?

Bill


Mime
View raw message