Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Modeling weird Windows pathnames

Reply
Thread Tools

Modeling weird Windows pathnames

 
 
Ian Pilcher
Guest
Posts: n/a
 
      01-27-2006
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
java.lang.String). I've currently modeled a path as:

* An (optional) "filesystem root",
* Zero or more directory names, and
* An (optional) file name.

This works find in a UNIX (Linux) environment, and it works for most
paths on Windows. It breaks down, however, when fed what I call a
"semi-absolute" path on Windows -- a path that begins with a drive
letter but no backslash (C:foo) or a path that begins with a single
backslash (\foo).

I'm just wondering if anyone has any ideas on how to model these sorts
of paths.

TIA

--
================================================== ======================
Ian Pilcher http://www.velocityreviews.com/forums/(E-Mail Removed)
================================================== ======================
 
Reply With Quote
 
 
 
 
Oliver Wong
Guest
Posts: n/a
 
      01-27-2006

"Ian Pilcher" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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
> java.lang.String). I've currently modeled a path as:
>
> * An (optional) "filesystem root",
> * Zero or more directory names, and
> * An (optional) file name.
>
> This works find in a UNIX (Linux) environment, and it works for most
> paths on Windows. It breaks down, however, when fed what I call a
> "semi-absolute" path on Windows -- a path that begins with a drive
> letter but no backslash (C:foo) or a path that begins with a single
> backslash (\foo).
>
> I'm just wondering if anyone has any ideas on how to model these sorts
> of paths.
>
> 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


 
Reply With Quote
 
 
 
 
Ian Pilcher
Guest
Posts: n/a
 
      01-27-2006
Oliver Wong wrote:
> 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!

--
================================================== ======================
Ian Pilcher (E-Mail Removed)
================================================== ======================
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to combine object-oriented modeling well with database modeling? tenxian Java 2 04-08-2008 01:02 AM
how to resolve Windows pathnames into cygwin ones mgierdal@gmail.com Python 6 01-18-2008 08:13 PM
Interest in conceptual data modeling (fact-based modeling)? Clifford Heath Ruby 2 02-07-2007 07:09 AM
favicon.ico and long pathnames Kevin Spencer ASP .Net 2 01-21-2004 02:31 PM
Relative Pathnames in an ASP program Ted Polak ASP .Net 1 08-12-2003 09:55 PM



Advertisments