
Signature
========================================================================
Ian Pilcher i.pilcher@comcast.net
========================================================================
> I'm working on a "tokenized path name" class, which will allow me to
> manipulate file and directory paths more easily than java.io.File (or
[quoted text clipped - 14 lines]
>
> TIA
Let's say this is the notation for a root "a" with 3 directory names "b",
"c" and "d", and a filename "e": ("a", "b", "c", "d", "e"). Here's the
notation for the same thing, but with the optional root ommited: (null, "b",
"c", "d", "e"). Similarly, for an omitted filename, ("a", "b", "c", "d",
null). We know that the first element is always the root, and the last
element is always the filename, and everything else must be directory names.
Linux: \usr\owong\Foo.java -> ("\", "\", "usr", "owong", "Foo.java")
Linux: owong\Foo.java -> (null, "owong", "Foo.java")
Windows: C:\Documents and Settings\owong\foo.java -> ("C:", "\", "Documents
and Settings", "owong", "foo.java")
Windows: owong\foo.java -> (null, "owong", "foo.java")
Windows: C:foo.java -> ("C:", "foo.java")
Windows: \foo.java -> (null, "\", "foo.java")
The idea is that in the most general case, you have a forest (i.e.
multiple trees), rather than a single rooted tree. The first element in the
list should indicate which tree you are dealing with (always "\" in the case
of Linux, but could be any drive letter in Windows). Every other element
should then be resolvable from your current location.
"\" always resolves to the root of the tree you're currently dealing
with, regardless of what the current location is. "a" should resolve to
whatever "a" is (either a directory or a file) in your current location.
So ("\", "\", "usr", "owong", "Foo.java") means: Use the tree known as "\"
(i.e. the Linux filesystem root), then resolve "\" in that tree (i.e. the
root of the filesystem), then resolve "usr" from there (the "usr" directory
in the root"), then resolve "owong" from there (the "owong" directory in the
"usr" directory) and so on.
(null, "owong", "foo.java") means the tree isn't specified, so used the
current tree, and then resolve "owong" from your current location in that
tree, and so on.
(null, "\", "foo.java") means the tree isn't specified, so used the current
tree, and then resolve "\" from your current location in that tree (and "\"
always resolves to the root of that tree), and so on.
- Oliver
Ian Pilcher - 27 Jan 2006 18:44 GMT
> The idea is that in the most general case, you have a forest (i.e.
> multiple trees), rather than a single rooted tree. The first element in the
> list should indicate which tree you are dealing with (always "\" in the case
> of Linux, but could be any drive letter in Windows). Every other element
> should then be resolvable from your current location.
Good stuff. I see now that I was conflating the idea of a "filesystem
root" with the idea of a root directory.
OTOH, I could just put everything in "My Computer".
Thanks!

Signature
========================================================================
Ian Pilcher i.pilcher@comcast.net
========================================================================