summaryrefslogtreecommitdiffstats
path: root/libjava/java/util/zip/ZipFile.java
diff options
context:
space:
mode:
authormark <mark@138bc75d-0d04-0410-961f-82ee72b054a4>2000-08-27 22:26:27 +0000
committermark <mark@138bc75d-0d04-0410-961f-82ee72b054a4>2000-08-27 22:26:27 +0000
commitcf3e246c38c1755fb0054ce57b4bc573c3312402 (patch)
treea46a5682294e3e06ba5793c02331a7c8ab8e3167 /libjava/java/util/zip/ZipFile.java
parent66784a64e6d660f047249ab6d4eafaf180744796 (diff)
downloadppe42-gcc-cf3e246c38c1755fb0054ce57b4bc573c3312402.tar.gz
ppe42-gcc-cf3e246c38c1755fb0054ce57b4bc573c3312402.zip
* java/util/zip/ZipFile.java: Implement OPEN_DELETE mode, new constructor,
close can delete the file, finalize calls close. * java/util/jar/JarFile.java: Constructor that takes mode now calls super. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@36007 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libjava/java/util/zip/ZipFile.java')
-rw-r--r--libjava/java/util/zip/ZipFile.java35
1 files changed, 32 insertions, 3 deletions
diff --git a/libjava/java/util/zip/ZipFile.java b/libjava/java/util/zip/ZipFile.java
index 43d72267aea..bb6eab47146 100644
--- a/libjava/java/util/zip/ZipFile.java
+++ b/libjava/java/util/zip/ZipFile.java
@@ -18,15 +18,35 @@ import java.io.*;
public class ZipFile implements ZipConstants
{
+ public static final int OPEN_READ = 1;
+ public static final int OPEN_DELETE = 4;
+
public ZipFile (String fname) throws IOException
{
- file = new RandomAccessFile(fname, "r");
- name = fname;
- readDirectory ();
+ this(new File(fname));
}
public ZipFile (File f) throws IOException
{
+ this(f, OPEN_READ);
+ }
+
+ public ZipFile (File f, int mode) throws IOException
+ {
+ if (mode != OPEN_READ && mode != (OPEN_READ | OPEN_DELETE))
+ throw new IllegalArgumentException
+ ("mode can only be OPEN_READ or OPEN_READ | OPEN_DELETE");
+
+ if ((mode & OPEN_DELETE) != 0)
+ {
+ delete_on_close = f;
+ // f.deleteOnExit(); XXX - Not yet implemented in libgcj
+ }
+ else
+ {
+ delete_on_close = null;
+ }
+
file = new RandomAccessFile(f, "r");
name = f.getName();
readDirectory ();
@@ -107,6 +127,8 @@ public class ZipFile implements ZipConstants
file.close();
entries = null;
numEntries = 0;
+ if (delete_on_close != null)
+ delete_on_close.delete();
}
public ZipEntry getEntry(String name)
@@ -148,6 +170,10 @@ public class ZipFile implements ZipConstants
return numEntries;
}
+ protected void finalize () throws IOException {
+ close();
+ }
+
private int readu2 () throws IOException
{
int byte0 = file.read();
@@ -173,6 +199,9 @@ public class ZipFile implements ZipConstants
int numEntries;
RandomAccessFile file;
String name;
+ /** File to delete on close or null. */
+ File delete_on_close;
+
}
final class ZipEnumeration implements java.util.Enumeration
OpenPOWER on IntegriCloud