org.eclipse.equinox.internal.p2.core.helpers.FileUtils类的使用及代码示例

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

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

FileUtils介绍

暂无

代码示例

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

public static void copy(File source, File destination, File root, boolean overwrite) throws IOException {
  File sourceFile = new File(source, root.getPath());
  if (!sourceFile.exists())
    throw new FileNotFoundException("Source: " + sourceFile + " does not exist"); //$NON-NLS-1$//$NON-NLS-2$
  File destinationFile = new File(destination, root.getPath());
  if (destinationFile.exists())
    if (overwrite)
      deleteAll(destinationFile);
    else
      throw new IOException("Destination: " + destinationFile + " already exists"); //$NON-NLS-1$//$NON-NLS-2$
  if (sourceFile.isDirectory()) {
    destinationFile.mkdirs();
    File[] list = sourceFile.listFiles();
    for (int i = 0; i < list.length; i++)
      copy(source, destination, new File(root, list[i].getName()), false);
  } else {
    destinationFile.getParentFile().mkdirs();
    try (InputStream in = new BufferedInputStream(new FileInputStream(sourceFile)); OutputStream out = new BufferedOutputStream(new FileOutputStream(destinationFile));) {
      copyStream(in, false, out, false);
    }
  }
}

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

protected IPathComputer createRootPrefixComputer(final File root) {
  return FileUtils.createRootPathComputer(root);
}

代码示例来源: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: com.github.veithen.cosmos.bootstrap/org.eclipse.equinox.p2.core

/**
 * Unzip from a File to an output directory.
 */
public static File[] unzipFile(File zipFile, File outputDir) throws IOException {
  // check to see if we have a tar'd and gz'd file
  if (zipFile.getName().toLowerCase().endsWith(".tar.gz")) { //$NON-NLS-1$
    try {
      return untarFile(zipFile, outputDir);
    } catch (TarException e) {
      throw new IOException(e.getMessage());
    }
  }
  InputStream in = new FileInputStream(zipFile);
  try {
    return unzipStream(in, zipFile.length(), outputDir, null, null);
  } catch (IOException e) {
    // add the file name to the message
    throw new IOException(NLS.bind(Messages.Util_Error_Unzipping, zipFile, e.getMessage()));
  } finally {
    in.close();
  }
}

代码示例来源: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);
} catch (IOException e) {
  return reportStatus(descriptor, destination, new Status(IStatus.ERROR, Activator.ID, e.getMessage()));

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

private void cleanupWorkDir() throws IOException {
  if (workDir != null) {
    FileUtils.deleteAll(workDir);
    // TODO try twice since there seems to be some cases where the dir is not 
    // deleted the first time.  At least on Windows...
    FileUtils.deleteAll(workDir);
  }
}

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

protected void performProcessing() throws IOException {
  File resultFile = null;
  try {
    resultFile = process();
    // now write the processed content to the destination
    if (resultFile.length() > 0) {
      InputStream resultStream = new BufferedInputStream(new FileInputStream(resultFile));
      FileUtils.copyStream(resultStream, true, getDestination(), false);
    } else {
      setStatus(new Status(IStatus.ERROR, Activator.ID, "Unpacking fails because intermediate file is empty: " + resultFile)); //$NON-NLS-1$
    }
  } finally {
    if (resultFile != null)
      resultFile.delete();
  }
}

代码示例来源: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);
} catch (ProvisionException e) {
  LogHelper.log(e.getStatus());

代码示例来源:origin: 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);
    zip(output, files[i], exclusions, pathComputer, directoryEntries);

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

zipDirectoryEntry(output, entryPath.removeLastSegments(1), source.lastModified(), directoryEntries);
  zipEntry.setTime(source.lastModified());
  output.putNextEntry(zipEntry);
  copyStream(input, true, output, false);
} catch (ZipException ze) {
  zipDirectoryEntry(output, new Path("META-INF"), source.lastModified(), directoryEntries); //$NON-NLS-1$

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

File outFile = createSubPathFile(outputDir, ze.getName());
unzippedFiles.add(outFile);
if (ze.isDirectory()) {
    copyStream(in, false, new FileOutputStream(outFile), true);
  } catch (FileNotFoundException e) {

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

public void makeTemporaryCopy() {
  if (isTemporary())
    return;
  File tempFile = null;
  try {
    tempFile = File.createTempFile("p2.brandingIron", ""); //$NON-NLS-1$ //$NON-NLS-2$
    tempFile.delete();
    for (File file : files)
      FileUtils.copy(location, tempFile, file, true);
  } catch (IOException e) {
    LogHelper.log(new Status(IStatus.ERROR, Activator.ID, "Error publishing artifacts", e)); //$NON-NLS-1$
  }
  location = tempFile;
  temporary = true;
}

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

public static void deleteEmptyDirs(File dir) throws IOException {
  File[] files = dir.listFiles();
  if (files != null) {
    for (int i = 0; i < files.length; i += 1) {
      deleteEmptyDirs(files[i]);
    }
    dir.getCanonicalFile().delete();
  }
}

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

protected IPathComputer createParentPrefixComputer(int segmentsToKeep) {
  return FileUtils.createParentPrefixComputer(segmentsToKeep);
}

代码示例来源: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);
} catch (IOException e) {
  return reportStatus(descriptor, destination, new Status(IStatus.ERROR, Activator.ID, e.getMessage(), e));

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

private void cleanupWorkDir() {
  if (workDir != null) {
    FileUtils.deleteAll(workDir);
    // TODO try twice since there seems to be some cases where the dir is not 
    // deleted the first time.  At least on Windows...
    FileUtils.deleteAll(workDir);
  }
}

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

protected void performProcessing() throws IOException {
  File resultFile = null;
  try {
    resultFile = process();
    // now write the processed content to the destination
    if (resultFile.length() > 0) {
      InputStream resultStream = new BufferedInputStream(new FileInputStream(resultFile));
      FileUtils.copyStream(resultStream, true, getDestination(), false);
    } else {
      setStatus(new Status(IStatus.ERROR, Activator.ID, "Unpacking fails because intermediate file is empty: " + resultFile)); //$NON-NLS-1$
    }
  } finally {
    if (resultFile != null)
      resultFile.delete();
  }
}

代码示例来源: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);
} catch (ProvisionException e) {
  LogHelper.log(e.getStatus());

代码示例来源:origin: at.bestsolution.efxclipse.eclipse/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);
    zip(output, files[i], exclusions, pathComputer, directoryEntries);

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

zipDirectoryEntry(output, entryPath.removeLastSegments(1), source.lastModified(), directoryEntries);
  zipEntry.setTime(source.lastModified());
  output.putNextEntry(zipEntry);
  copyStream(input, true, output, false);
} catch (ZipException ze) {
  zipDirectoryEntry(output, new Path("META-INF"), source.lastModified(), directoryEntries); //$NON-NLS-1$

相关文章