Thanks very much, much clearer indeed.
remove /. for all occurrences of /.
remove x/.. for all occurrences of /..
R.E. Boss
> -----Oorspronkelijk bericht-----
> Van:
programming-bounces@... [mailto:programming-
>
bounces@...] Namens Rob Hodgkinson
> Verzonden: donderdag 3 juli 2008 13:27
> Aan: Programming forum
> Onderwerp: Re: [Jprogramming] canonical pathname
>
> >From Raul ... (and being aware of the redirection problem Robert Raschke
> raised) ...
>
> .. Means the parent directory (one Œabove¹ the current directory
> . Means the current directory, so you can basically ignore these ones ...
>
> Thus stepwise to follow the filename parsing ...
>
> '/a/b/c/d/../../e/./f/../../f'
> ^^ ignore the /. So this becomes ...
> Œ/a/b/c/d/../../e/f/../../f¹
> ^^^^^ the /.. Moves back up to the /d directory
> level, so ...
> Œ/a/b/c/../e/f/../../f¹
> ^^^^^ ditto for /.. So then becomes ...
> Œ/a/b/e/f/../../f¹
> ^^^^^ ditto for /.. So then becomes ...
> Œ/a/b/e/../f¹
> ^^^^^ ditto for /.. So then becomes ...
> Œ/a/b/f¹
>
> So you don¹t ³remove² them, but ³parse² them to determine the ultimate
> filename.
>
> The Œlevels¹ of the directory are more obvious if you do ...
> ]boxes=:(<'/.')-.~ <;.1 '/a/b/c/d/../../e/./f/../../f'
> +--+--+--+--+---+---+--+--+---+---+--+
> |/a|/b|/c|/d|/..|/..|/e|/f|/..|/..|/f|
> +--+--+--+--+---+---+--+--+---+---+--+
> (<'/..')=boxes
> 0 0 0 0 1 1 0 0 1 1 0
> 1+_2*(<'/..')=boxes
> 1 1 1 1 _1 _1 1 1 _1 _1 1
> boxes,:<"0 +/\1+_2*(<'/..')=boxes
> +--+--+--+--+---+---+--+--+---+---+--+
> |/a|/b|/c|/d|/..|/..|/e|/f|/..|/..|/f|
> +--+--+--+--+---+---+--+--+---+---+--+
> |1 |2 |3 |4 |3 |2 |3 |4 |3 |2 |3 |
> +--+--+--+--+---+---+--+--+---+---+--+
>
> The last (key) step would be to keep the first Œunclosed¹ occurrence at
> each
> depth level, which here would return the first, second and last to produce
> the result Œ/a/b/f¹. A little tricky perhaps, so the regex solution is
> more
> Œready made¹.
>
> Hope that makes it clearer (and that I didn¹t goof !).
>
> Rob Hodgkinson
>
>
> On 3/07/08 5:07 PM, "R.E. Boss" <
r.e.boss@...> wrote:
>
> > Thanks, but even with this interpretation, I still do not understand how
> > removing all /.. and /. from '/a/b/c/d/../../e/./f/../../f' results in
> > '/a/b/f'
> >
> >
> > R.E. Boss
> >
> >
> >> > -----Oorspronkelijk bericht-----
> >> > Van:
programming-bounces@... [mailto:programming-
> >> >
bounces@...] Namens Raul Miller
> >> > Verzonden: woensdag 2 juli 2008 20:53
> >> > Aan: Programming forum
> >> > Onderwerp: Re: [Jprogramming] canonical pathname
> >> >
> >> > On 7/2/08, R.E. Boss <
r.e.boss@...> wrote:
> >>> > > If I remove all /.. and /. (or all '/..' and '/.') from
> >>> > > '/a/b/c/d/../../e/./f/../../f', I am left with '/a/b/c/d/e/f/f'
> >>> > > What is it I do not understand?
> >> >
> >> > These strings represent file system paths, where .
> >> > represents the current directory and .. represents
> >> > the current directory's parent directory.
> >> >
> >> > FYI,
> >> >
> >> > --
> >> > Raul
> >> > ---------------------------------------------------------------------
> -
> >> > For information about J forums see
>
http://www.jsoftware.com/forums.htm> >
> > ----------------------------------------------------------------------
> > For information about J forums see
http://www.jsoftware.com/forums.htm>
> ----------------------------------------------------------------------
> For information about J forums see
http://www.jsoftware.com/forums.htm