gpt4 book ai didi

org.eclipse.osgi.storage.bundlefile.ZipBundleFile类的使用及代码示例

转载 作者:知者 更新时间:2024-03-14 03:33:31 26 4
gpt4 key购买 nike

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

ZipBundleFile介绍

[英]A BundleFile that uses a ZipFile as it base file.
[中]使用ZipFile作为基础文件的BundleFile。

代码示例

代码示例来源:origin: at.bestsolution.efxclipse.eclipse/org.eclipse.osgi

public synchronized BundleEntry getEntry(String path) {
  if (!checkedOpen())
    return null;
  ZipEntry zipEntry = getZipEntry(path);
  if (zipEntry == null) {
    if (path.length() == 0 || path.charAt(path.length() - 1) == '/') {
      // this is a directory request lets see if any entries exist in this directory
      if (containsDir(path))
        return new DirZipBundleEntry(this, path);
    }
    return null;
  }
  return new ZipBundleEntry(zipEntry, this);
}

代码示例来源:origin: com.github.veithen.cosmos/cosmos-equinox

/**
 * Return an InputStream for the entry.
 *
 * @return InputStream for the entry
 * @exception java.io.IOException
 */
public InputStream getInputStream() throws IOException {
  ZipBundleFile zipBundleFile = bundleFile;
  if (!zipBundleFile.isMruEnabled())
    return bundleFile.getZipFile().getInputStream(zipEntry);
  zipBundleFile.incrementReference();
  InputStream result = null;
  try {
    return result = new ZipBundleEntryInputStream(zipBundleFile.getZipFile().getInputStream(zipEntry));
  } finally {
    if (result == null)
      // an exception occurred; decrement the reference
      zipBundleFile.decrementReference();
  }
}

代码示例来源:origin: org.eclipse.tycho/org.eclipse.osgi

@SuppressWarnings("deprecation")
  public URL getFileURL() {
    try {
      return bundleFile.extractDirectory(name).toURL();
    } catch (MalformedURLException e) {
      // this cannot happen.
      return null;
    }
  }
}

代码示例来源:origin: org.eclipse/osgi

/**
 * Extracts a directory and all sub content to disk
 * @param dirName the directory name to extract
 * @return the File used to extract the content to.  A value
 * of <code>null</code> is returned if the directory to extract does 
 * not exist or if content extraction is not supported.
 */
protected synchronized File extractDirectory(String dirName) {
  if (!checkedOpen())
    return null;
  Enumeration<? extends ZipEntry> entries = zipFile.entries();
  while (entries.hasMoreElements()) {
    String entryPath = entries.nextElement().getName();
    if (entryPath.startsWith(dirName) && !entryPath.endsWith("/")) //$NON-NLS-1$
      getFile(entryPath, false);
  }
  return getExtractFile(dirName);
}

代码示例来源:origin: org.eclipse/osgi

public synchronized File getFile(String entry, boolean nativeCode) {
  if (!checkedOpen())
    return null;
  ZipEntry zipEntry = getZipEntry(entry);
  if (zipEntry == null)
    return null;
    File nested = getExtractFile(zipEntry.getName());
    if (nested != null) {
      if (nested.exists()) {
        if (nested.isDirectory())
          extractDirectory(zipEntry.getName());
      } else {
        if (zipEntry.getName().endsWith("/")) { //$NON-NLS-1$
            throw new IOException(NLS.bind(Msg.ADAPTOR_DIRECTORY_CREATE_EXCEPTION, nested.getAbsolutePath()));
          extractDirectory(zipEntry.getName());
        } else {
          InputStream in = zipFile.getInputStream(zipEntry);

代码示例来源:origin: org.eclipse.tycho/org.eclipse.osgi

public File getFile(String entry, boolean nativeCode) {
  if (!lockOpen()) {
    return null;
    ZipEntry zipEntry = getZipEntry(entry);
    if (zipEntry == null)
      return null;
      File nested = getExtractFile(zipEntry.getName());
      if (nested != null) {
        if (nested.exists()) {
          if (nested.isDirectory())
            extractDirectory(zipEntry.getName());
        } else {
          if (zipEntry.getName().endsWith("/")) { //$NON-NLS-1$
              throw new IOException(NLS.bind(Msg.ADAPTOR_DIRECTORY_CREATE_EXCEPTION, nested.getAbsolutePath()));
            extractDirectory(zipEntry.getName());
          } else {
            InputStream in = zipFile.getInputStream(zipEntry);

代码示例来源:origin: com.diffplug.spotless/spotless-eclipse-base

private static BundleFile getBundlFile(Class<?> clazz) throws BundleException {
  URL objUrl = clazz.getProtectionDomain().getCodeSource().getLocation();
  File jarOrDirectory = new File(objUrl.getPath());
  if (!(jarOrDirectory.exists() && jarOrDirectory.canRead())) {
    throw new BundleException(String.format("Path '%s' for '%s' is not accessible exist on local file system.", objUrl, clazz.getName()), BundleException.READ_ERROR);
  }
  try {
    return jarOrDirectory.isDirectory() ? new DirBundleFile(jarOrDirectory, false) : new ZipBundleFile(jarOrDirectory, null, null, null);
  } catch (IOException e) {
    throw new BundleException(String.format("Cannot access bundle at '%s'.", jarOrDirectory), BundleException.READ_ERROR, e);
  }
}

代码示例来源:origin: org.eclipse/osgi

public void open() throws IOException {
  getZipFile();
}

代码示例来源:origin: com.github.veithen.cosmos/cosmos-equinox

throw new NullPointerException();
if (!checkedOpen())
  return null;
      getEntryPaths(path, entryPath.substring(path.length()), recurse, result);

代码示例来源:origin: org.eclipse.platform/org.eclipse.osgi

public BundleEntry getEntry(String path) {
  if (!lockOpen()) {
    return null;
  }
  try {
    ZipEntry zipEntry = getZipEntry(path);
    if (zipEntry == null) {
      if (path.length() == 0 || path.charAt(path.length() - 1) == '/') {
        // this is a directory request lets see if any entries exist in this directory
        if (containsDir(path))
          return new DirZipBundleEntry(this, path);
      }
      return null;
    }
    return new ZipBundleEntry(zipEntry, this);
  } finally {
    openLock.unlock();
  }
}

代码示例来源:origin: org.eclipse.platform/org.eclipse.osgi

/**
 * Extracts a directory and all sub content to disk
 * @param dirName the directory name to extract
 * @return the File used to extract the content to.  A value
 * of <code>null</code> is returned if the directory to extract does 
 * not exist or if content extraction is not supported.
 */
File extractDirectory(String dirName) {
  if (!lockOpen()) {
    return null;
  }
  try {
    Enumeration<? extends ZipEntry> entries = zipFile.entries();
    while (entries.hasMoreElements()) {
      String entryPath = entries.nextElement().getName();
      if (entryPath.startsWith(dirName) && !entryPath.endsWith("/")) //$NON-NLS-1$
        getFile(entryPath, false);
    }
    return getExtractFile(dirName);
  } finally {
    openLock.unlock();
  }
}

代码示例来源:origin: org.eclipse.platform/org.eclipse.osgi

@SuppressWarnings("deprecation")
  public URL getFileURL() {
    try {
      File file = bundleFile.getFile(zipEntry.getName(), false);
      if (file != null)
        return file.toURL();
    } catch (MalformedURLException e) {
      //This can not happen. 
    }
    return null;
  }
}

代码示例来源:origin: com.github.veithen.cosmos/cosmos-equinox

public void close() throws IOException {
  try {
    stream.close();
  } finally {
    synchronized (this) {
      if (closed)
        return;
      closed = true;
    }
    bundleFile.decrementReference();
  }
}

代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.osgi

private void getEntryPaths(String path, String entry, boolean recurse, LinkedHashSet<String> entries) {
  if (entry.length() == 0)
    return;
  int slash = entry.indexOf('/');
  if (slash == -1)
    entries.add(path + entry);
  else {
    path = path + entry.substring(0, slash + 1);
    entries.add(path);
    if (recurse)
      getEntryPaths(path, entry.substring(slash + 1), true, entries);
  }
}

代码示例来源:origin: org.eclipse.platform/org.eclipse.osgi

@Override
public Enumeration<String> getEntryPaths(String path, boolean recurse) {
  if (!lockOpen()) {
    return null;
          getEntryPaths(path, entryPath.substring(path.length()), recurse, result);

代码示例来源:origin: org.eclipse.tycho/org.eclipse.osgi

public ZipBundleEntryInputStream(InputStream stream) {
  super(stream);
  incrementReference();
}

代码示例来源:origin: com.github.veithen.cosmos/cosmos-equinox

public synchronized File getFile(String entry, boolean nativeCode) {
  if (!checkedOpen())
    return null;
  ZipEntry zipEntry = getZipEntry(entry);
  if (zipEntry == null)
    return null;
    File nested = getExtractFile(zipEntry.getName());
    if (nested != null) {
      if (nested.exists()) {
        if (nested.isDirectory())
          extractDirectory(zipEntry.getName());
      } else {
        if (zipEntry.getName().endsWith("/")) { //$NON-NLS-1$
            throw new IOException(NLS.bind(Msg.ADAPTOR_DIRECTORY_CREATE_EXCEPTION, nested.getAbsolutePath()));
          extractDirectory(zipEntry.getName());
        } else {
          InputStream in = zipFile.getInputStream(zipEntry);

代码示例来源:origin: at.bestsolution.efxclipse.eclipse/org.eclipse.osgi

/**
 * Extracts a directory and all sub content to disk
 * @param dirName the directory name to extract
 * @return the File used to extract the content to.  A value
 * of <code>null</code> is returned if the directory to extract does 
 * not exist or if content extraction is not supported.
 */
protected synchronized File extractDirectory(String dirName) {
  if (!checkedOpen())
    return null;
  Enumeration<? extends ZipEntry> entries = zipFile.entries();
  while (entries.hasMoreElements()) {
    String entryPath = entries.nextElement().getName();
    if (entryPath.startsWith(dirName) && !entryPath.endsWith("/")) //$NON-NLS-1$
      getFile(entryPath, false);
  }
  return getExtractFile(dirName);
}

代码示例来源:origin: org.eclipse.platform/org.eclipse.osgi

public File getFile(String entry, boolean nativeCode) {
  if (!lockOpen()) {
    return null;
    ZipEntry zipEntry = getZipEntry(entry);
    if (zipEntry == null)
      return null;
      File nested = getExtractFile(zipEntry.getName());
      if (nested != null) {
        if (nested.exists()) {
          if (nested.isDirectory())
            extractDirectory(zipEntry.getName());
        } else {
          if (zipEntry.getName().endsWith("/")) { //$NON-NLS-1$
              throw new IOException(NLS.bind(Msg.ADAPTOR_DIRECTORY_CREATE_EXCEPTION, nested.getAbsolutePath()));
            extractDirectory(zipEntry.getName());
          } else {
            InputStream in = zipFile.getInputStream(zipEntry);

代码示例来源:origin: org.eclipse.tycho/org.eclipse.osgi

public BundleFile createBundleFile(File content, Generation generation, boolean isDirectory, boolean isBase) {
  BundleFile result;
  try {
    if (isDirectory) {
      boolean strictPath = Boolean.parseBoolean(equinoxContainer.getConfiguration().getConfiguration(EquinoxConfiguration.PROPERTY_STRICT_BUNDLE_ENTRY_PATH, Boolean.FALSE.toString()));
      result = new DirBundleFile(content, strictPath);
    } else {
      result = new ZipBundleFile(content, generation, mruList, getConfiguration().getDebug());
    }
  } catch (IOException e) {
    throw new RuntimeException("Could not create bundle file.", e); //$NON-NLS-1$
  }
  return wrapBundleFile(result, generation, isBase);
}

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