commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Stephen Colebourne" <scolebou...@btopenworld.com>
Subject Re: [io] Filename prefixes
Date Tue, 23 Nov 2004 00:12:18 GMT
From: "Tim O'Brien" <tobrien@discursive.com>
> What happens to getExtension() when there is no "." character?
Then there is no extension, returns "".

> what is there are multiple ".", are you thinking name.substring(
name.lastIndexOf( "." ) + 1 )?
Yes

> What does getPrefix() return on Unix? Nothing?
absolute paths have a prefix of /
user directory paths are also a prefix (see lower down email)


The basic code is now checked in. I am currently only looking for windows
prefixes on windows, and unix prefixes on unix. Should this be
extended/simplified to look for all prefixes in all cases???

ie. on a PC running windows, should ~user/ be matched as a prefix????

I think it probably should now I've coded it the other way...

Stephen


> -----Original Message-----
> From: Stephen Colebourne [mailto:scolebourne@btopenworld.com]
> Sent: Sunday, November 21, 2004 7:18 PM
> To: Jakarta Commons Developers List
> Subject: Re: [io] Filename prefixes
>
> 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" <mfncooper@gmail.com>
> > On Mon, 22 Nov 2004 01:03:28 -0000, Stephen Colebourne
> > <scolebourne@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



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


Mime
View raw message