On 21/05/07, sebb <[EMAIL PROTECTED]> wrote:
On 21/05/07, Niall Pemberton <[EMAIL PROTECTED]> wrote:
> On 5/21/07, sebb <[EMAIL PROTECTED]> wrote:
> > Are there any plans to implement a filename relativiser?
> >
> > i.e., given an absolute directory and absolute filename it would
> > return a relative filename.
> >
> > e.g. (in Unix syntax):
> >
> > /a/b/c and /a/b/c/d/e.txt => d/e.txt
> >
> > and optionally:
> >
> > /a/b/c/f and /a/b/c/d/e.txt => ../d/e.txt
> >
> > It does not look particularly difficult to do, but it does not seem
> > trivial either, so it might be a useful addition to Commons IO...
>
> +1 sounds like a good candidate for FilenameUtils - commons JCI has a
> "relative" method in its ConverstionUtils class
                           s/stion/sion/
>
>  http://tinyurl.com/2kj6ul

Thanks. That would handle the first case above, but not the optional case.

Actually it does not handle

/a/b/c/ and /d/e/f/g.txt

as it assumes that the base is a proper parent of the file, which is
presumably true for JCI, but not for the general case I need.

The optional case probably needs a "dottiness" (!) limit - i.e. how
many ".." segments are allowed.

S.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to