diff options
Diffstat (limited to 'sources/scalac/util/AbstractFile.java')
-rw-r--r-- | sources/scalac/util/AbstractFile.java | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/sources/scalac/util/AbstractFile.java b/sources/scalac/util/AbstractFile.java index 2487e07ca3..7069df868b 100644 --- a/sources/scalac/util/AbstractFile.java +++ b/sources/scalac/util/AbstractFile.java @@ -39,6 +39,10 @@ public abstract class AbstractFile { */ public abstract boolean isDirectory(); + /** date file was last modified + */ + public abstract long lastModified(); + /** read content of the file into a byte[] buffer */ public abstract byte[] read() throws IOException; @@ -129,6 +133,10 @@ class PlainFile extends AbstractFile { return f.isDirectory(); } + public long lastModified() { + return f.lastModified(); + } + public byte[] read() throws IOException { FileInputStream in = new FileInputStream(f); int rest = (int)f.length(); @@ -196,6 +204,10 @@ class ZippedFile extends AbstractFile { return zipEntry.isDirectory(); } + public long lastModified() { + return zipEntry.getTime(); + } + public byte[] read() throws IOException { InputStream in = dir.zipFile.getInputStream(zipEntry); int rest = (int)zipEntry.getSize(); @@ -254,6 +266,10 @@ class ZipDir extends AbstractFile { return (zipFile != null); } + public long lastModified() { + return -1; + } + public byte[] read() throws IOException { throw new IOException("cannot read directory"); } @@ -322,6 +338,10 @@ final class JarArchive extends AbstractFile { return jarFile != null; } + public long lastModified() { + return -1; + } + public byte[] read() throws IOException { throw new IOException("cannot read archive"); } @@ -443,6 +463,10 @@ final class JarArchive extends AbstractFile { return true; } + public long lastModified() { + return -1; + } + public String[] list() throws IOException { throw new IOException("not a directory"); } @@ -510,6 +534,10 @@ final class JarArchive extends AbstractFile { return false; } + public long lastModified() { + return -1; + } + public String[] list() throws IOException { throw new IOException("not a directory"); } @@ -537,6 +565,10 @@ final class JarArchive extends AbstractFile { return true; } + public long lastModified() { + return jarFile.getJarEntry(name).getTime(); + } + public byte[] read() throws IOException { JarEntry jarEntry = jarFile.getJarEntry(name); if (jarEntry == null) |