File.java (deleteOnExit): New method.

* java/io/File.java (deleteOnExit): New method.
        * gnu/gcj/runtime/FileDeleter.java: New class.
        * java/lang/natRuntime.cc (exit): Call
        FileDeleter.deleteOnExitNow()
        * Makefile.am: Add FileDeleter.java.
        * Makefile.in: Rebuilt.

From-SVN: r36141
This commit is contained in:
Anthony Green 2000-09-04 16:55:48 +00:00
parent 4993ddc14f
commit 890a31f478
5 changed files with 60 additions and 2 deletions

View file

@ -10,6 +10,9 @@ details. */
package java.io;
import java.util.*;
import gnu.gcj.runtime.FileDeleter;
/**
* @author Tom Tromey <tromey@cygnus.com>
* @date September 24, 1998
@ -42,7 +45,7 @@ public class File implements Serializable
return access (p, WRITE);
}
private final native boolean performDelete (String canon);
private final native static boolean performDelete (String canon);
public boolean delete ()
{
SecurityManager s = System.getSecurityManager();
@ -347,6 +350,17 @@ public class File implements Serializable
return p;
}
// Add this File to the set of files to be deleted upon normal
// termination.
public void deleteOnExit ()
{
SecurityManager sm = System.getSecurityManager ();
if (sm != null)
sm.checkDelete (getName ());
FileDeleter.add (this);
}
// QUERY arguments to access function.
private final static int READ = 0;
private final static int WRITE = 1;