Ejemplo n.º 1
0
 private openjdk.com.sun.tools.javac.util.List<Entry> getEntries() {
   if (!zipFileEntriesInited) {
     initEntries();
     zipFileEntries = openjdk.com.sun.tools.javac.util.List.nil();
     for (Entry zfie : entries) {
       zipFileEntries = zipFileEntries.append(zfie);
     }
     zipFileEntriesInited = true;
   }
   return zipFileEntries;
 }
Ejemplo n.º 2
0
  public synchronized List<String> getDirectories(RelativeDirectory path) {
    try {
      checkIndex();

      DirectoryEntry de = directories.get(path);
      openjdk.com.sun.tools.javac.util.List<String> ret = de == null ? null : de.getDirectories();

      if (ret == null) {
        return openjdk.com.sun.tools.javac.util.List.<String>nil();
      }

      return ret;
    } catch (IOException e) {
      return openjdk.com.sun.tools.javac.util.List.<String>nil();
    }
  }
Ejemplo n.º 3
0
 private openjdk.com.sun.tools.javac.util.List<String> getDirectories() {
   if (!directoriesInited) {
     initEntries();
     for (Entry e : entries) {
       if (e.isDir) {
         zipFileEntriesDirectories = zipFileEntriesDirectories.append(e.name);
       }
     }
     directoriesInited = true;
   }
   return zipFileEntriesDirectories;
 }
Ejemplo n.º 4
0
  /**
   * ------------------------------------------------------------------------ DirectoryEntry class
   * -------------------------------------------------------------------------
   */
  static class DirectoryEntry {
    private boolean filesInited;
    private boolean directoriesInited;
    private boolean zipFileEntriesInited;
    private boolean entriesInited;

    private long writtenOffsetOffset = 0;

    private RelativeDirectory dirName;

    private openjdk.com.sun.tools.javac.util.List<String> zipFileEntriesFiles =
        openjdk.com.sun.tools.javac.util.List.<String>nil();
    private openjdk.com.sun.tools.javac.util.List<String> zipFileEntriesDirectories =
        openjdk.com.sun.tools.javac.util.List.<String>nil();
    private openjdk.com.sun.tools.javac.util.List<Entry> zipFileEntries =
        openjdk.com.sun.tools.javac.util.List.<Entry>nil();

    private List<Entry> entries = new ArrayList<Entry>();

    private ZipFileIndex zipFileIndex;

    private int numEntries;

    DirectoryEntry(RelativeDirectory dirName, ZipFileIndex index) {
      filesInited = false;
      directoriesInited = false;
      entriesInited = false;

      this.dirName = dirName;
      this.zipFileIndex = index;
    }

    private openjdk.com.sun.tools.javac.util.List<String> getFiles() {
      if (!filesInited) {
        initEntries();
        for (Entry e : entries) {
          if (!e.isDir) {
            zipFileEntriesFiles = zipFileEntriesFiles.append(e.name);
          }
        }
        filesInited = true;
      }
      return zipFileEntriesFiles;
    }

    private openjdk.com.sun.tools.javac.util.List<String> getDirectories() {
      if (!directoriesInited) {
        initEntries();
        for (Entry e : entries) {
          if (e.isDir) {
            zipFileEntriesDirectories = zipFileEntriesDirectories.append(e.name);
          }
        }
        directoriesInited = true;
      }
      return zipFileEntriesDirectories;
    }

    private openjdk.com.sun.tools.javac.util.List<Entry> getEntries() {
      if (!zipFileEntriesInited) {
        initEntries();
        zipFileEntries = openjdk.com.sun.tools.javac.util.List.nil();
        for (Entry zfie : entries) {
          zipFileEntries = zipFileEntries.append(zfie);
        }
        zipFileEntriesInited = true;
      }
      return zipFileEntries;
    }

    private Entry getEntry(String rootName) {
      initEntries();
      int index = Collections.binarySearch(entries, new Entry(dirName, rootName));
      if (index < 0) {
        return null;
      }

      return entries.get(index);
    }

    private void initEntries() {
      if (entriesInited) {
        return;
      }

      if (!zipFileIndex.readFromIndex) {
        int from =
            -Arrays.binarySearch(zipFileIndex.entries, new Entry(dirName, ZipFileIndex.MIN_CHAR))
                - 1;
        int to = -Arrays.binarySearch(zipFileIndex.entries, new Entry(dirName, MAX_CHAR)) - 1;

        for (int i = from; i < to; i++) {
          entries.add(zipFileIndex.entries[i]);
        }
      } else {
        File indexFile = zipFileIndex.getIndexFile();
        if (indexFile != null) {
          RandomAccessFile raf = null;
          try {
            raf = new RandomAccessFile(indexFile, "r");
            raf.seek(writtenOffsetOffset);

            for (int nFiles = 0; nFiles < numEntries; nFiles++) {
              // Read the name bytes
              int zfieNameBytesLen = raf.readInt();
              byte[] zfieNameBytes = new byte[zfieNameBytesLen];
              raf.read(zfieNameBytes);
              String eName = new String(zfieNameBytes, "UTF-8");

              // Read isDir
              boolean eIsDir = raf.readByte() == (byte) 0 ? false : true;

              // Read offset of bytes in the real Jar/Zip file
              int eOffset = raf.readInt();

              // Read size of the file in the real Jar/Zip file
              int eSize = raf.readInt();

              // Read compressed size of the file in the real Jar/Zip file
              int eCsize = raf.readInt();

              // Read java time stamp of the file in the real Jar/Zip file
              long eJavaTimestamp = raf.readLong();

              Entry rfie = new Entry(dirName, eName);
              rfie.isDir = eIsDir;
              rfie.offset = eOffset;
              rfie.size = eSize;
              rfie.compressedSize = eCsize;
              rfie.javatime = eJavaTimestamp;
              entries.add(rfie);
            }
          } catch (Throwable t) {
            // Do nothing
          } finally {
            try {
              if (raf != null) {
                raf.close();
              }
            } catch (Throwable t) {
              // Do nothing
            }
          }
        }
      }

      entriesInited = true;
    }

    List<Entry> getEntriesAsCollection() {
      initEntries();

      return entries;
    }
  }