commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dakota Jack <dakota.j...@gmail.com>
Subject Re: [fileUpload] Question about file name
Date Sat, 11 Jun 2005 14:14:32 GMT
Yup:

Frank,

If the File class does not normalize the string used to create the
File, then there is a bug.  There seems to be a bug in one version of
Linux and that has been reported to Sun.  The constructor for File is
as follows:


   public File(String pathname) {
       if (pathname == null) {
           throw new NullPointerException();
       }
       this.path = fs.normalize(pathname);
       this.prefixLength = fs.prefixLength(this.path);
   }

Notice that an object fs is called to normalize the pathname.  The
object fs is created as a static field in all File classes as follows:


   static private FileSystem fs = FileSystem.getFileSystem();

The FileSystem class is an abstract class that has to be implemented,
of course, for the os on which it exists.  So, the basis for the class
is a JNI method:

   public static native FileSystem getFileSystem();

Sun did not go to all this trouble without expecting the actual
separators to be normalized to whatever system a file is created on,
so that no matter what your path happens to be in creating a File
object, file.getName() should return the name without a file
separator.  Is this helpful?

On 6/9/05, Mihael Knezevic <m.knezevic@porta.de> wrote:
> this whole discussion is old. it can be found in the archives. the
> implementation of the jvm on linux FROM SUN is faulty on this one. cause when
> use use a filename like /tmp/mydir/myfile.txt and make a file object of it on
> a windows system and get the name you would get the name myfile.txt though
> the file separator on windows is a backslash, thats ok. but on linux you
> won't get the name from a windows path. i send a bug report to sun. there was
> some misunderstanding and then Dakota Jack <dakota.jack (at) gmail.com> send
> also a bug report to sun. perhaps it is in the bug list by now.
> 
> and yes the ie sends the full path. call it a bug or a feature.
> 
> just replacing the backslash with a slash won't solve every case but most
> cases.
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
> 
> 


-- 
"You can lead a horse to water but you cannot make it float on its back."
~Dakota Jack~

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


Mime
View raw message