org.eclipse.equinox.internal.p2.core.helpers.FileUtils.zip()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(9.3k)|赞(0)|评价(0)|浏览(131)

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

FileUtils.zip介绍

[英]Writes the given file or folder to the given ZipOutputStream. The stream is not closed, we recurse into folders
[中]将给定的文件或文件夹写入给定的ZipOutStream。流没有关闭,我们递归到文件夹中

代码示例

代码示例来源:origin: at.bestsolution.efxclipse.eclipse/org.eclipse.equinox.p2.core

/**
 * Writes the given file or folder to the given ZipOutputStream.  The stream is not closed, we recurse into folders
 * @param output - the ZipOutputStream to write into
 * @param source - the file or folder to zip
 * @param exclusions - set of files or folders to exclude
 * @param pathComputer - computer used to create the path of the files in the result.
 * @throws IOException
 */
public static void zip(ZipOutputStream output, File source, Set<File> exclusions, IPathComputer pathComputer) throws IOException {
  zip(output, source, exclusions, pathComputer, new HashSet<IPath>());
}

代码示例来源:origin: org.eclipse.equinox.p2/core

zip(output, files[i], exclusions, pathComputer, directoryEntries);

代码示例来源:origin: org.eclipse.equinox.p2/core

/**
 * Writes the given file or folder to the given ZipOutputStream.  The stream is not closed, we recurse into folders
 * @param output - the ZipOutputStream to write into
 * @param source - the file or folder to zip
 * @param exclusions - set of files or folders to exclude
 * @param pathComputer - computer used to create the path of the files in the result.
 * @throws IOException
 */
public static void zip(ZipOutputStream output, File source, Set<File> exclusions, IPathComputer pathComputer) throws IOException {
  zip(output, source, exclusions, pathComputer, new HashSet<IPath>());
}

代码示例来源:origin: at.bestsolution.efxclipse.eclipse/org.eclipse.equinox.p2.core

zip(output, files[i], exclusions, pathComputer, directoryEntries);

代码示例来源:origin: com.github.veithen.cosmos.bootstrap/org.eclipse.equinox.p2.core

/**
 * Writes the given file or folder to the given ZipOutputStream.  The stream is not closed, we recurse into folders
 * @param output - the ZipOutputStream to write into
 * @param source - the file or folder to zip
 * @param exclusions - set of files or folders to exclude
 * @param pathComputer - computer used to create the path of the files in the result.
 * @throws IOException
 */
public static void zip(ZipOutputStream output, File source, Set<File> exclusions, IPathComputer pathComputer) throws IOException {
  zip(output, source, exclusions, pathComputer, new HashSet<IPath>());
}

代码示例来源:origin: com.github.veithen.cosmos.bootstrap/org.eclipse.equinox.p2.core

zip(output, files[i], exclusions, pathComputer, directoryEntries);

代码示例来源:origin: org.eclipse.platform/org.eclipse.equinox.p2.core

/**
 * Writes the given file or folder to the given ZipOutputStream.  The stream is not closed, we recurse into folders
 * @param output - the ZipOutputStream to write into
 * @param source - the file or folder to zip
 * @param exclusions - set of files or folders to exclude
 * @param pathComputer - computer used to create the path of the files in the result.
 * @throws IOException
 */
public static void zip(ZipOutputStream output, File source, Set<File> exclusions, IPathComputer pathComputer) throws IOException {
  zip(output, source, exclusions, pathComputer, new HashSet<IPath>());
}

代码示例来源:origin: org.eclipse.platform/org.eclipse.equinox.p2.core

private static void zipDir(ZipOutputStream output, File source, Set<File> exclusions, IPathComputer pathComputer, Set<IPath> directoryEntries) throws IOException {
  File[] files = source.listFiles();
  if (files.length == 0) {
    zipDirectoryEntry(output, pathComputer.computePath(source), source.lastModified(), directoryEntries);
  }
  // Different OSs return files in a different order.  This affects the creation
  // the dynamic path computer.  To address this, we sort the files such that
  // those with deeper paths appear later, and files are always before directories
  // foo/bar.txt
  // foo/something/bar2.txt
  // foo/something/else/bar3.txt
  Arrays.sort(files, (arg0, arg1) -> {
    Path a = new Path(arg0.getAbsolutePath());
    Path b = new Path(arg1.getAbsolutePath());
    if (a.segmentCount() == b.segmentCount()) {
      if (arg0.isDirectory() && arg1.isFile())
        return 1;
      else if (arg0.isDirectory() && arg1.isDirectory())
        return 0;
      else if (arg0.isFile() && arg1.isDirectory())
        return -1;
      else
        return 0;
    }
    return a.segmentCount() - b.segmentCount();
  });
  for (int i = 0; i < files.length; i++)
    zip(output, files[i], exclusions, pathComputer, directoryEntries);
}

代码示例来源:origin: org.eclipse.platform/org.eclipse.equinox.p2.core

/**
 * Creates a zip archive at the given destination that contains all of the given inclusions
 * except for the given exclusions.  Inclusions and exclusions can be phrased as files or folders.
 * Including a folder implies that all files and folders under the folder 
 * should be considered for inclusion. Excluding a folder implies that all files and folders
 * under that folder will be excluded. Inclusions with paths deeper than an exclusion folder
 * are filtered out and do not end up in the resultant archive.
 * <p>
 * All entries in the archive are computed using the given path computer.  the path computer
 * is reset between every explicit entry in the inclusions list.
 * </p>
 * @param inclusions the set of files and folders to be considered for inclusion in the result
 * @param exclusions the set of files and folders to be excluded from the result.  May be <code>null</code>.
 * @param destinationArchive the location of the resultant archive
 * @param pathComputer the path computer used to create the path of the files in the result
 * @throws IOException if there is an IO issue during this operation.
 */
public static void zip(File[] inclusions, File[] exclusions, File destinationArchive, IPathComputer pathComputer) throws IOException {
  try (FileOutputStream fileOutput = new FileOutputStream(destinationArchive); ZipOutputStream output = new ZipOutputStream(fileOutput)) {
    HashSet<File> exclusionSet = exclusions == null ? new HashSet<>() : new HashSet<>(Arrays.asList(exclusions));
    HashSet<IPath> directoryEntries = new HashSet<>();
    for (int i = 0; i < inclusions.length; i++) {
      pathComputer.reset();
      zip(output, inclusions[i], exclusionSet, pathComputer, directoryEntries);
    }
  }
}

代码示例来源:origin: org.eclipse.equinox.p2/core

for (int i = 0; i < inclusions.length; i++) {
  pathComputer.reset();
  zip(output, inclusions[i], exclusionSet, pathComputer, directoryEntries);

代码示例来源:origin: com.github.veithen.cosmos.bootstrap/org.eclipse.equinox.p2.core

for (int i = 0; i < inclusions.length; i++) {
  pathComputer.reset();
  zip(output, inclusions[i], exclusionSet, pathComputer, directoryEntries);

代码示例来源:origin: at.bestsolution.efxclipse.eclipse/org.eclipse.equinox.p2.core

for (int i = 0; i < inclusions.length; i++) {
  pathComputer.reset();
  zip(output, inclusions[i], exclusionSet, pathComputer, directoryEntries);

代码示例来源:origin: org.eclipse.platform/org.eclipse.equinox.p2.publisher

output = new BufferedOutputStream(output);
tempFile = File.createTempFile("p2.generator", ""); //$NON-NLS-1$ //$NON-NLS-2$
FileUtils.zip(inclusions, exclusions, tempFile, prefixComputer);
if (output != null)
  FileUtils.copyStream(new BufferedInputStream(new FileInputStream(tempFile)), true, output, true);

代码示例来源:origin: org.eclipse.equinox.p2/publisher

output = new BufferedOutputStream(output);
tempFile = File.createTempFile("p2.generator", ""); //$NON-NLS-1$ //$NON-NLS-2$
FileUtils.zip(inclusions, exclusions, tempFile, prefixComputer);
if (output != null)
  FileUtils.copyStream(new BufferedInputStream(new FileInputStream(tempFile)), true, output, true);

代码示例来源:origin: at.bestsolution.efxclipse.eclipse/org.eclipse.equinox.p2.publisher

output = new BufferedOutputStream(output);
tempFile = File.createTempFile("p2.generator", ""); //$NON-NLS-1$ //$NON-NLS-2$
FileUtils.zip(inclusions, exclusions, tempFile, prefixComputer);
if (output != null)
  FileUtils.copyStream(new BufferedInputStream(new FileInputStream(tempFile)), true, output, true);

代码示例来源:origin: com.github.veithen.cosmos.bootstrap/org.eclipse.equinox.p2.publisher

output = new BufferedOutputStream(output);
tempFile = File.createTempFile("p2.generator", ""); //$NON-NLS-1$ //$NON-NLS-2$
FileUtils.zip(inclusions, exclusions, tempFile, prefixComputer);
if (output != null)
  FileUtils.copyStream(new BufferedInputStream(new FileInputStream(tempFile)), true, output, true);

代码示例来源:origin: com.github.veithen.cosmos.bootstrap/org.eclipse.equinox.p2.artifact.repository

try {
  zipFile = File.createTempFile(artifactFolder.getName(), JAR_EXTENSION, null);
  FileUtils.zip(artifactFolder.listFiles(), null, zipFile, FileUtils.createRootPathComputer(artifactFolder));
  FileInputStream fis = new FileInputStream(zipFile);
  totalArtifactSize += FileUtils.copyStream(fis, true, destination, false);

代码示例来源:origin: org.eclipse.platform/org.eclipse.equinox.p2.artifact.repository

try {
  zipFile = File.createTempFile(artifactFolder.getName(), JAR_EXTENSION, null);
  FileUtils.zip(artifactFolder.listFiles(), null, zipFile, FileUtils.createRootPathComputer(artifactFolder));
  FileInputStream fis = new FileInputStream(zipFile);
  totalArtifactSize += FileUtils.copyStream(fis, true, destination, false);

代码示例来源:origin: org.eclipse.equinox.p2.artifact/repository

try {
  zipFile = File.createTempFile(artifactFolder.getName(), JAR_EXTENSION, null);
  FileUtils.zip(artifactFolder.listFiles(), null, zipFile, FileUtils.createRootPathComputer(artifactFolder));
  FileInputStream fis = new FileInputStream(zipFile);
  totalArtifactSize += FileUtils.copyStream(fis, true, destination, false);

代码示例来源:origin: at.bestsolution.efxclipse.eclipse/org.eclipse.equinox.p2.artifact.repository

try {
  zipFile = File.createTempFile(artifactFolder.getName(), JAR_EXTENSION, null);
  FileUtils.zip(artifactFolder.listFiles(), null, zipFile, FileUtils.createRootPathComputer(artifactFolder));
  FileInputStream fis = new FileInputStream(zipFile);
  totalArtifactSize += FileUtils.copyStream(fis, true, destination, false);

相关文章