Пример #1
0
  @NotNull
  private FileAccessorCache.Handle<ZipFile> getZipFileHandle() throws IOException {
    FileAccessorCache.Handle<ZipFile> handle = ourZipFileFileAccessorCache.get(this);

    if (getFile() == getFileToUse()) { // files are canonicalized
      // IDEA-148458, http://bugs.java.com/view_bug.do?bug_id=4425695, JVM crashes on use of opened
      // ZipFile after it was updated
      // Reopen file if the file has been changed
      FileAttributes attributes = FileSystemUtil.getAttributes(getCanonicalPathToZip());
      if (attributes == null) {
        throw new FileNotFoundException(getCanonicalPathToZip());
      }

      if (attributes.lastModified == myFileStamp && attributes.length == myFileLength)
        return handle;

      // Note that zip_util.c#ZIP_Get_From_Cache will allow us to have duplicated ZipFile instances
      // without a problem
      removeZipHandlerFromCache();
      handle.release();
      handle = ourZipFileFileAccessorCache.get(this);
    }

    return handle;
  }
Пример #2
0
 // also used in Kotlin
 public static void clearFileAccessorCache() {
   ourZipFileFileAccessorCache.clear();
 }
Пример #3
0
 private void removeZipHandlerFromCache() {
   ourZipFileFileAccessorCache.remove(this);
 }