This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

libgcj/1759: java.io.File lacks several jdk 1.2 methods



>Number:         1759
>Category:       libgcj
>Synopsis:       java.io.File lacks several jdk 1.2 methods
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Wed Jan 24 09:16:01 PST 2001
>Closed-Date:
>Last-Modified:
>Originator:     ptf@ftel.co.uk
>Release:        2.97
>Organization:
>Environment:
Linux
Reading specs from /opt/gcc-snap/lib/gcc-lib/i686-pc-linux-gnu/2.97/specs
Reading specs from /opt/gcc-snap/lib/gcc-lib/i686-pc-linux-gnu/2.97/../../../libgcj.spec
rename spec lib to liborig
rename spec startfile to startfileorig
Configured with: ../gcc/configure --prefix=/opt/gcc-snap --enable-languages=c,c++,java
gcc version 2.97 20010124 (experimental)
>Description:
java.io.File lacks several JDK 1.2 methods.

>How-To-Repeat:
n/a
>Fix:
This doesn't  supply all of the missing methods - just
the ones that are important to me at the moment.



Index: File.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/io/File.java,v
retrieving revision 1.14
diff -c -r1.14 File.java
*** File.java   2000/09/08 19:37:08     1.14
--- File.java   2001/01/24 16:58:14
***************
*** 12,17 ****
--- 12,19 ----
  
  import java.util.*;
  import gnu.gcj.runtime.FileDeleter;
+ import java.net.URL;
+ import java.net.MalformedURLException;
  
  /**
   * @author Tom Tromey <tromey@cygnus.com>
***************
*** 106,113 ****
--- 108,125 ----
      return System.getProperty("user.dir") + separatorChar + path;
    }
  
+   public File getAbsoluteFile() 
+   {
+     return new File(getAbsolutePath());
+   }
+ 
    public native String getCanonicalPath () throws IOException;
  
+   public File getCanonicalFile() throws IOException
+   {
+     return new File(getCanonicalPath());
+   }
+ 
    public String getName ()
    {
      int last = path.lastIndexOf(separatorChar);
***************
*** 173,178 ****
--- 185,210 ----
      return performList (checkRead (), null);
    }
  
+   public File[] listFiles(FilenameFilter filter) 
+   {
+     String[] files = performList (checkRead (), filter);
+     if (files != null)
+       {
+       File[] list = new File[files.length];
+       for (int i = 0; i < files.length; i++)
+         {
+           list[i] = new File(path, files[i]);
+         }
+       return list;
+       }
+     return null;
+   }
+ 
+   public File[] listFiles() 
+   {
+     return listFiles(null);
+   }
+ 
    public String toString ()
    {
      return path;
***************
*** 316,321 ****
--- 348,382 ----
      return createTempFile (prefix, suffix, null);
    }
  
+   public boolean createNewFile() 
+     throws IOException 
+   {
+     SecurityManager s = System.getSecurityManager();
+     if (s != null)
+       {
+       s.checkWrite(path);
+       }
+     // This is a bit of a kludge!
+     try 
+       {
+       // FIXME - the file ends up with mode 0600, quite likely this
+       // isn't what was expected.
+       FileDescriptor fd = 
+         new FileDescriptor (path, FileDescriptor.WRITE | FileDescriptor.EXCL);
+       fd.close ();
+       }
+     catch (FileNotFoundException x)
+       {
+         // Assumes unix-like error messages
+         if (x.getMessage().indexOf("exists") == -1)
+           throw x;
+         else
+           return false;
+       }
+     return true;
+   }
+ 
+ 
    private final native boolean performRenameTo (File dest);
    public boolean renameTo (File dest)
    {
***************
*** 327,332 ****
--- 388,399 ----
        s.checkWrite(safeCanonicalPath());
        }
      return performRenameTo (dest);
+   }
+ 
+   public URL toURL()
+     throws MalformedURLException 
+   {
+     return new URL("file://" + getAbsolutePath());
    }
  
    public static final String pathSeparator

>Release-Note:
>Audit-Trail:
>Unformatted:

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]