gpt4 book ai didi

com.sun.tools.javac.file.ZipFileIndex类的使用及代码示例

转载 作者:知者 更新时间:2024-03-19 00:05:31 25 4
gpt4 key购买 nike

本文整理了Java中com.sun.tools.javac.file.ZipFileIndex类的一些代码示例,展示了ZipFileIndex类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZipFileIndex类的具体详情如下:
包路径:com.sun.tools.javac.file.ZipFileIndex
类名称:ZipFileIndex

ZipFileIndex介绍

[英]This class implements the building of index of a zip archive and access to its context. It also uses a prebuilt index if available. It supports invocations where it will serialize an optimized zip index file to disk. In order to use a secondary index file, set "usezipindex" in the Options object when JavacFileManager is invoked. (You can pass "-XDusezipindex" on the command line.) Location where to look for/generate optimized zip index files can be provided using " -XDcachezipindexdir=". If this flag is not provided, the default location is the value of the "java.io.tmpdir" system property. If "-XDwritezipindexfiles" is specified, there will be new optimized index file created for each archive, used by the compiler for compilation, at the location specified by the "cachezipindexdir" option. If system property nonBatchMode option is specified the compiler will use timestamp checking to reindex the zip files if it is needed. In batch mode the timestamps are not checked and the compiler uses the cached indexes.

This is NOT part of any supported API. If you write code that depends on this, you do so at your own risk. This code and its internal interfaces are subject to change or deletion without notice.
[中]这个类实现了zip存档的索引构建和对其上下文的访问。如果可用,它还使用预建索引。它支持将优化的zip索引文件序列化到磁盘的调用。为了使用辅助索引文件,在调用JavacFileManager时,在Options对象中设置“usezipindex”。(可以在命令行上传递“-XDusezipindex”。)可以使用“-XDcachezipindexdir=”提供查找/生成优化zip索引文件的位置。如果未提供此标志,则默认位置为“java.io.tmpdir”系统属性的值。如果指定了“-XDwritezipindexfiles”,则将在“cachezipindexdir”选项指定的位置为每个存档创建新的优化索引文件,供编译器用于编译。如果指定了system property nonBatchMode选项,编译器将使用时间戳检查来重新索引zip文件(如果需要)。在批处理模式下,不检查时间戳,编译器使用缓存的索引。
这不是任何受支持的API的一部分。如果您编写的代码依赖于此,那么您将自担风险。本代码及其内部接口如有更改或删除,恕不另行通知。

代码示例

代码示例来源:origin: org.kohsuke.sorcerer/sorcerer-javac

/**
 * Returns the last modified timestamp of a zip file.
 * @return long
 */
public long getZipFileLastModified() throws IOException {
  synchronized (this) {
    checkIndex();
    return zipFileLastModified;
  }
}

代码示例来源:origin: org.kohsuke.sorcerer/sorcerer-javac

public void close() throws IOException {
  zfIndex.close();
}

代码示例来源:origin: org.kohsuke.sorcerer/sorcerer-javac

synchronized byte[] read(Entry entry) throws IOException {
  openFile();
  byte[] result = readBytes(entry);
  closeFile();
  return result;
}

代码示例来源:origin: org.kohsuke.sorcerer/sorcerer-javac

public synchronized void close() {
  writeIndex();
  closeFile();
}

代码示例来源:origin: org.kohsuke.sorcerer/sorcerer-javac

/**
 * Tests if a specific path exists in the zip.  This method will return true
 * for file entries and directories.
 *
 * @param path A path within the zip.
 * @return True if the path is a file or dir, false otherwise.
 */
public synchronized boolean contains(RelativePath path) {
  try {
    checkIndex();
    return getZipIndexEntry(path) != null;
  }
  catch (IOException e) {
    return false;
  }
}

代码示例来源:origin: sc.fiji/javac

private byte[] readBytes(Entry entry) throws IOException {
  byte[] header = getHeader(entry);
  int csize = entry.compressedSize;
  byte[] cbuf = new byte[csize];
  zipRandomFile.skipBytes(get2ByteLittleEndian(header, 26) + get2ByteLittleEndian(header, 28));
  zipRandomFile.readFully(cbuf, 0, csize);
  // is this compressed - offset 8 in the ZipEntry header
  if (get2ByteLittleEndian(header, 8) == 0)
    return cbuf;
  int size = entry.size;
  byte[] buf = new byte[size];
  if (inflate(cbuf, buf) != size)
    throw new ZipException("corrupted zip file");
  return buf;
}

代码示例来源:origin: sc.fiji/javac

if (!isUpToDate()) {
  closeFile();
  isUpToDate = false;
if (readIndex()) {
  lastReferenceTimeStamp = System.currentTimeMillis();
  return;
  openFile();
  long totalLength = zipRandomFile.length();
  ZipDirectory directory = new ZipDirectory(zipRandomFile, 0L, totalLength, this);
} finally {
  if (zipRandomFile != null) {
    closeFile();

代码示例来源:origin: konsoletyper/teavm-javac

public synchronized int length(RelativeFile path) throws IOException {
  Entry entry = getZipIndexEntry(path);
  if (entry == null)
    throw new FileNotFoundException();
  if (entry.isDir) {
    return 0;
  }
  byte[] header = getHeader(entry);
  // entry is not compressed?
  if (get2ByteLittleEndian(header, 8) == 0) {
    return entry.compressedSize;
  } else {
    return entry.size;
  }
}

代码示例来源:origin: org.kohsuke.sorcerer/sorcerer-javac

private byte[] getHeader(Entry entry) throws IOException {
  zipRandomFile.seek(entry.offset);
  byte[] header = new byte[30];
  zipRandomFile.readFully(header);
  if (get4ByteLittleEndian(header, 0) != 0x04034b50)
    throw new ZipException("corrupted zip file");
  if ((get2ByteLittleEndian(header, 6) & 1) != 0)
    throw new ZipException("encrypted zip file"); // offset 6 in the header of the ZipFileEntry
  return header;
}

代码示例来源:origin: org.kohsuke.sorcerer/sorcerer-javac

/**
 * Check if two file objects are equal.
 * Two ZipFileIndexFileObjects are equal if the absolute paths of the underlying
 * zip files are equal and if the paths within those zip files are equal.
 */
@Override
public boolean equals(Object other) {
  if (this == other)
    return true;
  if (!(other instanceof ZipFileIndexFileObject))
    return false;
  ZipFileIndexFileObject o = (ZipFileIndexFileObject) other;
  return zfIndex.getAbsoluteFile().equals(o.zfIndex.getAbsoluteFile())
      && name.equals(o.name);
}

代码示例来源:origin: sc.fiji/javac

public static ZipFileIndex getZipFileIndex(File zipFile,
    RelativeDirectory symbolFilePrefix,
    boolean useCache, String cacheLocation,
    boolean writeIndex) throws IOException {
  ZipFileIndex zi = null;
  lock.lock();
  try {
    zi = getExistingZipIndex(zipFile);
    if (zi == null || (zi != null && zipFile.lastModified() != zi.zipFileLastModified)) {
      zi = new ZipFileIndex(zipFile, symbolFilePrefix, writeIndex,
          useCache, cacheLocation);
      zipFileIndexCache.put(zipFile, zi);
    }
  }
  finally {
    lock.unlock();
  }
  return zi;
}

代码示例来源:origin: sc.fiji/javac

protected void finalize() {
  closeFile();
}

代码示例来源:origin: org.kohsuke.sorcerer/sorcerer-javac

public boolean contains(RelativePath name) {
  return zfIndex.contains(name);
}

代码示例来源:origin: org.kohsuke.sorcerer/sorcerer-javac

public List<String> getFiles(RelativeDirectory subdirectory) {
  return zfIndex.getFiles(subdirectory);
}

代码示例来源:origin: org.kohsuke.sorcerer/sorcerer-javac

public Set<RelativeDirectory> getSubdirectories() {
  return zfIndex.getAllDirectories();
}

代码示例来源:origin: org.kohsuke.sorcerer/sorcerer-javac

public synchronized ZipFileIndex getZipFileIndex(File zipFile,
    RelativeDirectory symbolFilePrefix,
    boolean useCache, String cacheLocation,
    boolean writeIndex) throws IOException {
  ZipFileIndex zi = getExistingZipIndex(zipFile);
  if (zi == null || (zi != null && zipFile.lastModified() != zi.zipFileLastModified)) {
    zi = new ZipFileIndex(zipFile, symbolFilePrefix, writeIndex,
        useCache, cacheLocation);
    map.put(zipFile, zi);
  }
  return zi;
}

代码示例来源:origin: org.kohsuke.sorcerer/sorcerer-javac

private byte[] readBytes(Entry entry) throws IOException {
  byte[] header = getHeader(entry);
  int csize = entry.compressedSize;
  byte[] cbuf = new byte[csize];
  zipRandomFile.skipBytes(get2ByteLittleEndian(header, 26) + get2ByteLittleEndian(header, 28));
  zipRandomFile.readFully(cbuf, 0, csize);
  // is this compressed - offset 8 in the ZipEntry header
  if (get2ByteLittleEndian(header, 8) == 0)
    return cbuf;
  int size = entry.size;
  byte[] buf = new byte[size];
  if (inflate(cbuf, buf) != size)
    throw new ZipException("corrupted zip file");
  return buf;
}

代码示例来源:origin: org.kohsuke.sorcerer/sorcerer-javac

if (!isUpToDate()) {
  closeFile();
  isUpToDate = false;
if (readIndex()) {
  lastReferenceTimeStamp = System.currentTimeMillis();
  return;
  openFile();
  long totalLength = zipRandomFile.length();
  ZipDirectory directory = new ZipDirectory(zipRandomFile, 0L, totalLength, this);
} finally {
  if (zipRandomFile != null) {
    closeFile();

代码示例来源:origin: org.kohsuke.sorcerer/sorcerer-javac

public synchronized int length(RelativeFile path) throws IOException {
  Entry entry = getZipIndexEntry(path);
  if (entry == null)
    throw new FileNotFoundException();
  if (entry.isDir) {
    return 0;
  }
  byte[] header = getHeader(entry);
  // entry is not compressed?
  if (get2ByteLittleEndian(header, 8) == 0) {
    return entry.compressedSize;
  } else {
    return entry.size;
  }
}

代码示例来源:origin: sc.fiji/javac

private byte[] getHeader(Entry entry) throws IOException {
  zipRandomFile.seek(entry.offset);
  byte[] header = new byte[30];
  zipRandomFile.readFully(header);
  if (get4ByteLittleEndian(header, 0) != 0x04034b50)
    throw new ZipException("corrupted zip file");
  if ((get2ByteLittleEndian(header, 6) & 1) != 0)
    throw new ZipException("encrypted zip file"); // offset 6 in the header of the ZipFileEntry
  return header;
}

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com