ZipFileIndex.java revision 332
0N/A * In oreder to use secondary index file make sure the option "usezipindex" is in the Options object,
0N/A * checking to reindex the zip files if it is needed. In batch mode the timestamps are not checked
0N/Apublic class ZipFileIndex {
0N/A private static boolean NON_BATCH_MODE = System.getProperty("nonBatchMode") != null;// TODO: Use -XD compiler switch for this.
102N/A private Map<RelativeDirectory, DirectoryEntry> directories = Collections.<RelativeDirectory, DirectoryEntry>emptyMap();
0N/A private boolean readFromIndex = false;
0N/A private boolean triedToReadIndex = false;
0N/A private boolean hasPopulatedData = false;
0N/A private boolean usePreindexedCache = false;
0N/A private boolean writeIndex = false;
0N/A return getZipFileIndexes(false);
0N/A if (openedOnly) {
0N/A return zipFileIndexes;
0N/A public static void clearCache() {
0N/A throw new IllegalStateException("Setting opened indexes should be called only when the ZipFileCache is empty. Call JavacFileManager.flush() before calling this method.");
0N/A checkIndex();
0N/A private boolean isUpToDate() {
0N/A * Here we need to make sure that the ZipFileIndex is valid. Check the timestamp of the file and
0N/A boolean isUpToDate = true;
0N/A if (!isUpToDate()) {
0N/A isUpToDate = false;
0N/A hasPopulatedData = true;
0N/A private void cleanupState() {
0N/A writeIndex();
0N/A checkIndex();
0N/A catch (IOException e) {
0N/A checkIndex();
0N/A catch (IOException e) {
0N/A checkIndex();
0N/A catch (IOException e) {
0N/A checkIndex();
0N/A catch (IOException e) {
0N/A checkIndex();
0N/A catch (IOException e) {
0N/A checkIndex();
0N/A throw new FileNotFoundException();
0N/A throw new FileNotFoundException();
0N/A throw new FileNotFoundException();
0N/A throws IOException {
0N/A private class ZipDirectory {
0N/A public ZipDirectory(RandomAccessFile zipRandomFile, long start, long end, ZipFileIndex index) throws IOException {
0N/A // There is a variable-length field after the dir offset record. We need to do consequential search.
0N/A cleanupState();
0N/A checkIndex();
0N/A return zipFileLastModified;
0N/A static class DirectoryEntry {
0N/A private boolean filesInited;
0N/A private boolean directoriesInited;
0N/A private boolean zipFileEntriesInited;
0N/A private boolean entriesInited;
0N/A private com.sun.tools.javac.util.List<String> zipFileEntriesFiles = com.sun.tools.javac.util.List.<String>nil();
0N/A private com.sun.tools.javac.util.List<String> zipFileEntriesDirectories = com.sun.tools.javac.util.List.<String>nil();
56N/A private com.sun.tools.javac.util.List<Entry> zipFileEntries = com.sun.tools.javac.util.List.<Entry>nil();
0N/A private int numEntries;
102N/A filesInited = false;
0N/A directoriesInited = false;
0N/A entriesInited = false;
102N/A if (!filesInited) {
102N/A filesInited = true;
0N/A return zipFileEntriesFiles;
102N/A if (!directoriesInited) {
102N/A directoriesInited = true;
0N/A return zipFileEntriesDirectories;
102N/A if (!zipFileEntriesInited) {
102N/A zipFileEntriesInited = true;
0N/A return zipFileEntries;
0N/A initEntries();
0N/A private void initEntries() {
0N/A if (entriesInited) {
0N/A entriesInited = true;
0N/A initEntries();
0N/A triedToReadIndex = true;
0N/A readFromIndex = true;
0N/A private boolean writeIndex() {
0N/A if (!writeIndex) {
0N/A public boolean writeZipIndex() {
0N/A return writeIndex();
0N/A return zipIndexFile;
56N/A int compressedSize;
56N/A private int nativetime;
56N/A public long getLastModified() {
70N/A return c.getTimeInMillis();
56N/A public boolean isDirectory() {