org.codehaus.plexus.util.FileUtils.copyDirectoryStructure()方法的使用及代码示例

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

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

FileUtils.copyDirectoryStructure介绍

[英]Copies a entire directory structure.

Note:

  • It will include empty directories.
  • The sourceDirectory must exists.
    [中]复制整个目录结构。
    注:
    *它将包括空目录。
    *sourceDirectory必须存在。

代码示例

代码示例来源:origin: org.codehaus.plexus/plexus-utils

/**
 * <p>Copies a entire directory structure.</p>
 * 
 * Note:
 * <ul>
 * <li>It will include empty directories.
 * <li>The <code>sourceDirectory</code> must exists.
 * </ul>
 *
 * @param sourceDirectory the source dir
 * @param destinationDirectory the target dir
 * @throws IOException if any
 */
public static void copyDirectoryStructure( File sourceDirectory, File destinationDirectory )
  throws IOException
{
  copyDirectoryStructure( sourceDirectory, destinationDirectory, destinationDirectory, false );
}

代码示例来源:origin: org.codehaus.plexus/plexus-utils

/**
 * <p>Copies an entire directory structure but only source files with timestamp later than the destinations'.</p>
 * 
 * Note:
 * <ul>
 * <li>It will include empty directories.
 * <li>The <code>sourceDirectory</code> must exists.
 * </ul>
 *
 * @param sourceDirectory the source dir
 * @param destinationDirectory the target dir
 * @throws IOException if any
 */
public static void copyDirectoryStructureIfModified( File sourceDirectory, File destinationDirectory )
  throws IOException
{
  copyDirectoryStructure( sourceDirectory, destinationDirectory, destinationDirectory, true );
}

代码示例来源:origin: MovingBlocks/Terasology

/**
 * Copies the selected save files to a new recording directory.
 *
 * @param oldTitle The name of the original save directory.
 * @param newTitle The name of the new recording directory.
 */
private void copySaveDirectoryToRecordingLibrary(String oldTitle, String newTitle) {
  File saveDirectory = new File(PathManager.getInstance().getSavePath(oldTitle).toString());
  Path destinationPath = PathManager.getInstance().getRecordingPath(newTitle);
  File destDirectory = new File(destinationPath.toString());
  try {
    FileUtils.copyDirectoryStructure(saveDirectory, destDirectory);
    rewriteManifestTitle(destinationPath, newTitle);
  } catch (Exception e) {
    logger.error("Error trying to copy the save directory:", e);
  }
}

代码示例来源:origin: org.codehaus.plexus/plexus-utils

copyDirectoryStructure( file, destination, rootDestinationDirectory, onlyModifiedFiles );

代码示例来源:origin: org.apache.maven.plugin-testing/maven-plugin-testing-harness

/**
 * Creates new clean copy of test project directory structure. The copy is named after both the test being executed
 * and test project name, which allows the same test project can be used by multiple tests and by different
 * instances of the same parametrized tests.<br/>
 * TODO Provide alternative working directory naming for Windows, which still limits path names to ~250 charecters
 */
public File getBasedir( String project )
  throws IOException
{
  if ( name == null )
  {
    throw new IllegalStateException( getClass().getSimpleName()
      + " must be a test class field annotated with org.junit.Rule" );
  }
  File src = new File( projectsDir, project ).getCanonicalFile();
  Assert.assertTrue( "Test project directory does not exist: " + src.getPath(), src.isDirectory() );
  File basedir = new File( workDir, name + "_" + project ).getCanonicalFile();
  FileUtils.deleteDirectory( basedir );
  Assert.assertTrue( "Test project working directory created", basedir.mkdirs() );
  FileUtils.copyDirectoryStructure( src, basedir );
  return basedir;
}

代码示例来源:origin: org.apache.servicemix.kernel.gshell/org.apache.servicemix.kernel.gshell.core

/**
 * Copies a entire directory structure.
 * <p/>
 * Note:
 * <ul>
 * <li>It will include empty directories.
 * <li>The <code>sourceDirectory</code> must exists.
 * </ul>
 *
 * @param sourceDirectory
 * @param destinationDirectory
 * @throws IOException
 */
public static void copyDirectoryStructure( File sourceDirectory, File destinationDirectory )
  throws IOException
{
  copyDirectoryStructure( sourceDirectory, destinationDirectory, destinationDirectory, false );
}

代码示例来源:origin: org.apache.servicemix.kernel.gshell/org.apache.servicemix.kernel.gshell.core

/**
 * Copies an entire directory structure but only source files with timestamp later than the destinations'.
 * <p/>
 * Note:
 * <ul>
 * <li>It will include empty directories.
 * <li>The <code>sourceDirectory</code> must exists.
 * </ul>
 *
 * @param sourceDirectory
 * @param destinationDirectory
 * @throws IOException
 */
public static void copyDirectoryStructureIfModified( File sourceDirectory, File destinationDirectory )
  throws IOException
{
  copyDirectoryStructure( sourceDirectory, destinationDirectory, destinationDirectory, true );
}

代码示例来源:origin: synergian/wagon-git

public void putDirectory(File sourceDirectory, String destinationDirectory) throws IOException {

    FileUtils.copyDirectoryStructure(sourceDirectory, new File(workDir, destinationDirectory));

  }
}

代码示例来源:origin: org.sonatype.buup/buup-runtime

protected File backupFile( File file )
  throws IOException
{
  File bf = new File( originalFile.getParentFile(), originalFile.getName() + ".buup-bak" );
  if ( file.isFile() )
  {
    FileUtils.copyFile( file, bf );
  }
  else if ( file.isDirectory() )
  {
    FileUtils.copyDirectoryStructure( file, bf );
  }
  return bf;
}

代码示例来源:origin: org.sonatype.tycho/tycho-testing-harness

protected File getBasedir(String test) throws IOException {
  File src = new File("projects", test).getCanonicalFile();
  File dst = new File("target/projects", test).getCanonicalFile();
  if (dst.isDirectory()) {
    FileUtils.deleteDirectory(dst);
  } else if (dst.isFile()) {
    if (!dst.delete()) {
      throw new IOException("Can't delete file " + dst.toString());
    }
  }

  FileUtils.copyDirectoryStructure(src, dst);
  
  return dst;
}

代码示例来源:origin: net.flexmojos.oss/flexmojos-maven-plugin

private void copyFolderTemplate( String path )
  throws MojoExecutionException
{
  File source = new File( path );
  if ( !source.isAbsolute() )
  {
    source = new File( project.getBasedir(), path );
  }
  if ( !source.exists() || !source.isDirectory() )
  {
    throw new MojoExecutionException( "Template folder doesn't exists. " + source );
  }
  try
  {
    FileUtils.copyDirectoryStructure( source, templateOutputDirectory );
  }
  catch ( IOException e )
  {
    throw new MojoExecutionException( "Unable to copy template to: " + templateOutputDirectory, e );
  }
}

代码示例来源:origin: org.eclipse.tycho/tycho-testing-harness

protected File getBasedir(String test) throws IOException {
  File src = new File("projects", test).getAbsoluteFile();
  File dst = new File("target/projects", getClass().getSimpleName() + "/" + name.getMethodName() + "/" + test)
      .getAbsoluteFile();
  if (dst.isDirectory()) {
    FileUtils.deleteDirectory(dst);
  } else if (dst.isFile()) {
    if (!dst.delete()) {
      throw new IOException("Can't delete file " + dst.toString());
    }
  }
  FileUtils.copyDirectoryStructure(src, dst);
  return dst;
}

代码示例来源:origin: org.apache.maven.scm/maven-scm-provider-gittest

public static void initRepo( String source, File repository, File workingDirectory )
  throws IOException
{
  // Copy the repository to target
  File src = PlexusTestCase.getTestFile( source );
  FileUtils.deleteDirectory( repository );
  Assert.assertTrue( repository.mkdirs() );
  FileUtils.copyDirectoryStructure( src, repository );
  File dotGitDirectory = new File( src, "dotgit" );
  if ( dotGitDirectory.exists() )
  {
    FileUtils.copyDirectoryStructure( dotGitDirectory, new File( repository, ".git" ) );
  }
  FileUtils.deleteDirectory( workingDirectory );
  Assert.assertTrue( workingDirectory.mkdirs() );
}

代码示例来源:origin: apache/maven-scm

public static void initRepo( String source, File repository, File workingDirectory )
  throws IOException
{
  // Copy the repository to target
  File src = PlexusTestCase.getTestFile( source );
  FileUtils.deleteDirectory( repository );
  Assert.assertTrue( repository.mkdirs() );
  FileUtils.copyDirectoryStructure( src, repository );
  File dotGitDirectory = new File( src, "dotgit" );
  if ( dotGitDirectory.exists() )
  {
    FileUtils.copyDirectoryStructure( dotGitDirectory, new File( repository, ".git" ) );
  }
  FileUtils.deleteDirectory( workingDirectory );
  Assert.assertTrue( workingDirectory.mkdirs() );
}

代码示例来源:origin: org.eclipse.tycho/tycho-testing-harness

public static File getBasedir(String name) throws IOException {
    File src = new File(PlexusTestCase.getBasedir(), "src/test/resources/" + name);
    File dst = new File(PlexusTestCase.getBasedir(), "target/" + name);

    if (dst.isDirectory()) {
      FileUtils.deleteDirectory(dst);
    } else if (dst.isFile()) {
      if (!dst.delete()) {
        throw new IOException("Can't delete file " + dst.toString());
      }
    }

    FileUtils.copyDirectoryStructure(src, dst);

    return dst;
  }
}

代码示例来源:origin: io.takari.maven.plugins/takari-plugin-testing

/**
 * Creates new clean copy of test project directory structure. The copy is named after both the test being executed and test project name, which allows the same test project can be used by multiple
 * tests and by different instances of the same parametrized tests.<br/>
 * TODO Provide alternative working directory naming for Windows, which still limits path names to ~250 charecters
 */
public File getBasedir(String project) throws IOException {
 if (name == null) {
  throw new IllegalStateException(getClass().getSimpleName() + " must be a test class field annotated with org.junit.Rule");
 }
 File basedir = new File(workDir, name + "_" + project).getCanonicalFile();
 FileUtils.deleteDirectory(basedir);
 Assert.assertTrue("Test project working directory created", basedir.mkdirs());
 File src = new File(projectsDir, project).getCanonicalFile();
 Assert.assertTrue("Test project directory does not exist: " + src.getPath(), src.isDirectory());
 FileUtils.copyDirectoryStructure(src, basedir);
 return basedir;
}

代码示例来源:origin: apache/maven-scm

public static void initRepo( String source, File repository, File workingDirectory )
    throws IOException
  {
    // Copy the repository to target
    File src = PlexusTestCase.getTestFile( source );

    FileUtils.deleteDirectory( repository );

    Assert.assertTrue( repository.mkdirs() );

    FileUtils.copyDirectoryStructure( src, repository );

    FileUtils.deleteDirectory( workingDirectory );

    Assert.assertTrue( workingDirectory.mkdirs() );
  }
}

代码示例来源:origin: org.sonatype.tycho/tycho-testing-harness

public static File getBasedir( String name )
    throws IOException
  {
    File src = new File( PlexusTestCase.getBasedir(), "src/test/resources/" + name );
    File dst = new File( PlexusTestCase.getBasedir(), "target/" + name );

    if ( dst.isDirectory() )
    {
      FileUtils.deleteDirectory( dst );
    }
    else if ( dst.isFile() )
    {
      if ( !dst.delete() )
      {
        throw new IOException( "Can't delete file " + dst.toString() );
      }
    }

    FileUtils.copyDirectoryStructure( src, dst );

    return dst;
  }
}

代码示例来源:origin: org.eclipse.tycho/sisu-equinox-launching

private List<String> unpackFrameworkExtensions(File location, Collection<File> frameworkExtensions)
    throws IOException {
  List<String> bundleNames = new ArrayList<>();
  for (File bundleFile : frameworkExtensions) {
    OsgiManifest mf = manifestReader.loadManifest(bundleFile);
    bundleNames.add(mf.getBundleSymbolicName());
    File bundleDir = new File(location, "plugins/" + mf.getBundleSymbolicName() + "_" + mf.getBundleVersion());
    if (bundleFile.isFile()) {
      unpack(bundleFile, bundleDir);
    } else {
      FileUtils.copyDirectoryStructure(bundleFile, bundleDir);
    }
  }
  return bundleNames;
}

代码示例来源:origin: org.eclipse.tycho/tycho-equinox-launching

private List<String> unpackFrameworkExtensions(File location, Collection<File> frameworkExtensions)
    throws IOException {
  List<String> bundleNames = new ArrayList<String>();
  for (File bundleFile : frameworkExtensions) {
    Manifest mf = manifestReader.loadManifest(bundleFile);
    ManifestElement[] id = manifestReader.parseHeader(Constants.BUNDLE_SYMBOLICNAME, mf);
    ManifestElement[] version = manifestReader.parseHeader(Constants.BUNDLE_VERSION, mf);
    if (id == null || version == null) {
      throw new IOException("Invalid OSGi manifest in bundle " + bundleFile);
    }
    bundleNames.add(id[0].getValue());
    File bundleDir = new File(location, "plugins/" + id[0].getValue() + "_" + version[0].getValue());
    if (bundleFile.isFile()) {
      unpack(bundleFile, bundleDir);
    } else {
      FileUtils.copyDirectoryStructure(bundleFile, bundleDir);
    }
  }
  return bundleNames;
}

相关文章