You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Stephen Colebourne <sc...@btopenworld.com> on 2004/11/22 02:03:28 UTC

[io] Filename prefixes

In order to write the normalize() method properly, I realised that we have
to deal with filename prefixes properly. The point being that you can't ..
up into a filename prefix.

Here's the javadoc for the method I'm writing. Does this cover the cases?

    /**
     * Returns the length of the filename prefix, such as <code>C:/</code>
or <code>~/</code>.
     * <p>
     * This method will handle a file in either Unix or Windows format.
     * The prefix includes the first slash in the full filename.
     * <pre>
     * Windows:
     * a\b\c.txt           --> ""          --> relative
     * \a\b\c.txt          --> "\"         --> drive relative
     * C:\a\b\c.txt        --> "C:\"       --> absolute
     * \\server\a\b\c.txt  --> "\\server\" --> UNC
     *
     * Unix:
     * a/b/c.txt           --> ""          --> relative
     * /a/b/c.txt          --> "/"         --> absolute
     * ~/a/b/c.txt         --> "~/"        --> current user relative
     * ~user/a/b/c.txt     --> "~user/"    --> named user relative
     * </pre>
     *
     * @param filename  the filename to find the prefix in, null returns -1
     * @return the length of the prefix, -1 if invalid or null
     */

Stephen


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


Re: [io] Filename prefixes

Posted by Martin Cooper <mf...@gmail.com>.
On Mon, 22 Nov 2004 01:17:40 -0000, Stephen Colebourne
<sc...@btopenworld.com> wrote:
> Basically it looks like we'll need:
> 
> getPrefix()  - C:\
> getPath()  - dev\project
> getFullPath()  - C:\dev\project
> getName()  - file.txt
> getExtension()  - txt
> (input  C:\dev\project\file.txt)

Perhaps one more:
getBaseName() - file

> Normalize/catPath can then use the other methods to stitch together a
> result.
> 
> Naming:
> catPath() should be renamed to concat()

That's fine. I think your earlier suggestion was merge(), but I like
concat() better. ;-)

> getFullPath()/getPath() - are these logical names?

I think getFullPath() is fine. I'm not so thrilled with getPath(),
since I suspect people might expect it to do what getFullPath() does,
but I don't have any good suggestions for an alternative name.

I'm fine with the use of the term 'prefix', since I've seen it used
elsewhere with the same meaning.

--
Martin Cooper


> 
> Stephen
> 
> 
> 
> ----- Original Message -----
> From: "Martin Cooper" <mf...@gmail.com>
> > On Mon, 22 Nov 2004 01:03:28 -0000, Stephen Colebourne
> > <sc...@btopenworld.com> wrote:
> > > In order to write the normalize() method properly, I realised that we
> have
> > > to deal with filename prefixes properly. The point being that you can't
> ..
> > > up into a filename prefix.
> > >
> > > Here's the javadoc for the method I'm writing. Does this cover the
> cases?
> >
> > Looks good to me. I can't think of any other options, at least for
> > Windows and Unix.
> >
> > --
> > Martin Cooper
> >
> >
> > >
> > >    /**
> > >     * Returns the length of the filename prefix, such as
> <code>C:/</code>
> > > or <code>~/</code>.
> > >     * <p>
> > >     * This method will handle a file in either Unix or Windows format.
> > >     * The prefix includes the first slash in the full filename.
> > >     * <pre>
> > >     * Windows:
> > >     * a\b\c.txt           --> ""          --> relative
> > >     * \a\b\c.txt          --> "\"         --> drive relative
> > >     * C:\a\b\c.txt        --> "C:\"       --> absolute
> > >     * \\server\a\b\c.txt  --> "\\server\" --> UNC
> > >     *
> > >     * Unix:
> > >     * a/b/c.txt           --> ""          --> relative
> > >     * /a/b/c.txt          --> "/"         --> absolute
> > >     * ~/a/b/c.txt         --> "~/"        --> current user relative
> > >     * ~user/a/b/c.txt     --> "~user/"    --> named user relative
> > >     * </pre>
> > >     *
> > >     * @param filename  the filename to find the prefix in, null
> returns -1
> > >     * @return the length of the prefix, -1 if invalid or null
> > >     */
> > >
> > > Stephen
> > >
> > > ---------------------------------------------------------------------
> > > 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
> >
> 
> 
> ---------------------------------------------------------------------
> 
> 
> 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 prefixes

Posted by Stephen Colebourne <sc...@btopenworld.com>.
Basically it looks like we'll need:

getPrefix()  - C:\
getPath()  - dev\project
getFullPath()  - C:\dev\project
getName()  - file.txt
getExtension()  - txt
(input  C:\dev\project\file.txt)

Normalize/catPath can then use the other methods to stitch together a
result.

Naming:
catPath() should be renamed to concat()
getFullPath()/getPath() - are these logical names?

Stephen

----- Original Message -----
From: "Martin Cooper" <mf...@gmail.com>
> On Mon, 22 Nov 2004 01:03:28 -0000, Stephen Colebourne
> <sc...@btopenworld.com> wrote:
> > In order to write the normalize() method properly, I realised that we
have
> > to deal with filename prefixes properly. The point being that you can't
..
> > up into a filename prefix.
> >
> > Here's the javadoc for the method I'm writing. Does this cover the
cases?
>
> Looks good to me. I can't think of any other options, at least for
> Windows and Unix.
>
> --
> Martin Cooper
>
>
> >
> >    /**
> >     * Returns the length of the filename prefix, such as
<code>C:/</code>
> > or <code>~/</code>.
> >     * <p>
> >     * This method will handle a file in either Unix or Windows format.
> >     * The prefix includes the first slash in the full filename.
> >     * <pre>
> >     * Windows:
> >     * a\b\c.txt           --> ""          --> relative
> >     * \a\b\c.txt          --> "\"         --> drive relative
> >     * C:\a\b\c.txt        --> "C:\"       --> absolute
> >     * \\server\a\b\c.txt  --> "\\server\" --> UNC
> >     *
> >     * Unix:
> >     * a/b/c.txt           --> ""          --> relative
> >     * /a/b/c.txt          --> "/"         --> absolute
> >     * ~/a/b/c.txt         --> "~/"        --> current user relative
> >     * ~user/a/b/c.txt     --> "~user/"    --> named user relative
> >     * </pre>
> >     *
> >     * @param filename  the filename to find the prefix in, null
returns -1
> >     * @return the length of the prefix, -1 if invalid or null
> >     */
> >
> > Stephen
> >
> > ---------------------------------------------------------------------
> > 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
>


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


Re: [io] Filename prefixes

Posted by Stephen Colebourne <sc...@btopenworld.com>.
Prefix is the name used internally in the JDK File/FileSystem class. I'm not
completely averse to alternatives, but I do quite like the 'prefix'. Mainly,
I think thats because we are dealing with filenames here not files.

Stephen

----- Original Message -----
From: "Simon Kitching" <si...@ecnetwork.co.nz>
> I don't have any comment on the implementation, but I'm not wild on the
> use of the name "filename prefix".
>
> Perhaps "file origin" (as in a graph origin, being the point that
> coordinates are relative to)? Or "file source"?
>
> Regards,
>
> Simon
>
>
> ---------------------------------------------------------------------
> 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 prefixes

Posted by Simon Kitching <si...@ecnetwork.co.nz>.
Hi,

I don't have any comment on the implementation, but I'm not wild on the
use of the name "filename prefix".

Perhaps "file origin" (as in a graph origin, being the point that
coordinates are relative to)? Or "file source"?

Regards,

Simon


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


Re: [io] Filename prefixes

Posted by Martin Cooper <mf...@gmail.com>.
On Mon, 22 Nov 2004 01:03:28 -0000, Stephen Colebourne
<sc...@btopenworld.com> wrote:
> In order to write the normalize() method properly, I realised that we have
> to deal with filename prefixes properly. The point being that you can't ..
> up into a filename prefix.
> 
> Here's the javadoc for the method I'm writing. Does this cover the cases?

Looks good to me. I can't think of any other options, at least for
Windows and Unix.

--
Martin Cooper


> 
>    /**
>     * Returns the length of the filename prefix, such as <code>C:/</code>
> or <code>~/</code>.
>     * <p>
>     * This method will handle a file in either Unix or Windows format.
>     * The prefix includes the first slash in the full filename.
>     * <pre>
>     * Windows:
>     * a\b\c.txt           --> ""          --> relative
>     * \a\b\c.txt          --> "\"         --> drive relative
>     * C:\a\b\c.txt        --> "C:\"       --> absolute
>     * \\server\a\b\c.txt  --> "\\server\" --> UNC
>     *
>     * Unix:
>     * a/b/c.txt           --> ""          --> relative
>     * /a/b/c.txt          --> "/"         --> absolute
>     * ~/a/b/c.txt         --> "~/"        --> current user relative
>     * ~user/a/b/c.txt     --> "~user/"    --> named user relative
>     * </pre>
>     *
>     * @param filename  the filename to find the prefix in, null returns -1
>     * @return the length of the prefix, -1 if invalid or null
>     */
> 
> Stephen
> 
> ---------------------------------------------------------------------
> 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