You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by sebb <se...@gmail.com> on 2007/05/21 17:24:10 UTC

[IO] Filename relativiser?

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...

S.

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Re: [IO] Filename relativiser?

Posted by Niall Pemberton <ni...@gmail.com>.
On 5/22/07, sebb <se...@gmail.com> wrote:
> On 21/05/07, sebb <se...@gmail.com> wrote:
> > On 21/05/07, Niall Pemberton <ni...@gmail.com> wrote:
> > > On 5/21/07, sebb <se...@gmail.com> 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.

Just thought it would be good to consider JCI's use case when
considering a new feature for IO.

Niall

> > The optional case probably needs a "dottiness" (!) limit - i.e. how
> > many ".." segments are allowed.
> >
> > S.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-dev-help@jakarta.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Re: [IO] Filename relativiser?

Posted by sebb <se...@gmail.com>.
On 21/05/07, sebb <se...@gmail.com> wrote:
> On 21/05/07, Niall Pemberton <ni...@gmail.com> wrote:
> > On 5/21/07, sebb <se...@gmail.com> 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: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Re: [IO] Filename relativiser?

Posted by sebb <se...@gmail.com>.
On 21/05/07, Niall Pemberton <ni...@gmail.com> wrote:
> On 5/21/07, sebb <se...@gmail.com> 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.

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

S.

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Re: [IO] Filename relativiser?

Posted by Niall Pemberton <ni...@gmail.com>.
On 5/21/07, sebb <se...@gmail.com> 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

  http://tinyurl.com/2kj6ul

Niall

> S.

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org