On Wed, Mar 14, 2001 at 03:29:49PM -0600, William A. Rowe, Jr. wrote:
> From: "Kevin Pilch-Bisson" <[EMAIL PROTECTED]>
> 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
> 
> 
Right.  Now say the target was D:foo, but my current drive was C:, as in
D:\mywork\subversion> C:
C:\Program Files\Subversion> svn commit D:foo

How do I find out that D:foo is really D:\mywork\subversion\foo?

On another note, I thought of another root case to be handled under
UNIX.  Cygwin with windows drives.  I.e. / is %SYSDRIVE%:\, but //c/ is
C:\ and //d/ is D:\.  The double slashes are important to cygwin.

What a PITA.  Sometimes I don't know whether I am glad for cygwin
because it makes having to use 'Doze at work less annoying, or pissed of
because of the hassle it makes for real unix development!
-- 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Kevin Pilch-Bisson                    http://www.pilch-bisson.net
     "Historically speaking, the presences of wheels in Unix
     has never precluded their reinvention." - Larry Wall
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Reply via email to