classpath-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [cp-patches] Patch: File.getParent fixlet


From: Wolfgang Baer
Subject: Re: [cp-patches] Patch: File.getParent fixlet
Date: Sun, 06 Nov 2005 19:06:00 +0100
User-agent: Debian Thunderbird 1.0.7 (X11/20051017)

Mark Wielaard wrote:
Hi Wolfgang,

On Fri, 2005-10-28 at 20:47 +0200, Wolfgang Baer wrote:

File.getParent fails with an Exception for a file with
a pathname of "".

A corresponding mauve test is send to mauve-patches.

2005-10-28  Wolfgang Baer  <address@hidden>

        * java/io/File.java
          (getParent): If pathname is "" return null.


We talked a bit about the test on mauve-patches and you said that you
would supply another test that tested some more properties of the "empty
File name". Could you post that and tell us if the above patch is still
valid?

These are the fixlets needed to make java.io.File pass the submitted
mauve tests for an empty file ( new File("") ).

2005-11-06  Wolfgang Baer  <address@hidden>

        * java/io/File.java
          (getParent): If pathname is "" return null.
          (toURI): Also append separatorChar if path equals "".
          (getAbsolutePath): If path equals "" only return the value
           of the user.dir system property.

Regards,
Wolfgang

Index: java/io/File.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/io/File.java,v
retrieving revision 1.58
diff -u -r1.58 File.java
--- java/io/File.java   24 Oct 2005 06:44:19 -0000      1.58
+++ java/io/File.java   6 Nov 2005 17:49:46 -0000
@@ -457,6 +457,8 @@
         else
           return drvDir;
       }
+    else if (path.equals(""))
+       return System.getProperty ("user.dir");
     else
       return System.getProperty ("user.dir") + separatorChar + path;
   }
@@ -543,6 +545,9 @@
   {
     String prefix = null;
     int nameSeqIndex = 0;
+    
+    if (path.equals(""))
+      return null;
 
     // The "prefix", if present, is the leading "/" on UNIX and 
     // either the drive specifier (e.g. "C:") or the leading "\\"
@@ -954,8 +959,8 @@
   public URI toURI()
   {
     String abspath = getAbsolutePath();
-
-    if (isDirectory())
+       
+    if (isDirectory() || path.equals(""))
       abspath = abspath + separatorChar;
 
     if (separatorChar == '\\')

reply via email to

[Prev in Thread] Current Thread [Next in Thread]