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

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

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

FileUtils.cleanDirectory介绍

[英]Clean a directory without deleting it.
[中]清除目录而不删除它。

代码示例

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

/**
 * Clean a directory without deleting it.
 *
 * @param directory a directory
 * @throws IOException if any
 */
public static void cleanDirectory( final String directory )
  throws IOException
{
  cleanDirectory( new File( directory ) );
}

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

/**
 * Recursively delete a directory.
 *
 * @param directory a directory
 * @throws IOException if any
 */
public static void deleteDirectory( final File directory )
  throws IOException
{
  if ( !directory.exists() )
  {
    return;
  }
  /*
   * try delete the directory before its contents, which will take care of any directories that are really
   * symbolic links.
   */
  if ( directory.delete() )
  {
    return;
  }
  cleanDirectory( directory );
  if ( !directory.delete() )
  {
    final String message = "Directory " + directory + " unable to be deleted.";
    throw new IOException( message );
  }
}

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

@After
public void cleanUp()
    throws IOException {
  FileUtils.cleanDirectory(new File(TMP_SAVES_FOLDER_PATH.toUri()));
  FileUtils.cleanDirectory(new File(TMP_RECORDS_FOLDER_PATH.toUri()));
}

代码示例来源:origin: apache/usergrid

String extractedRunnerPath = getExtractedRunnerPath();
if ( FileUtils.fileExists( extractedRunnerPath ) ) {
  FileUtils.cleanDirectory( extractedRunnerPath );

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

/**
 * Clean a directory without deleting it.
 */
public static void cleanDirectory( final String directory )
  throws IOException
{
  cleanDirectory( new File( directory ) );
}

代码示例来源:origin: skwakman/nodejs-maven-plugin

private void prepareTargetDirectory(File targetDir) throws MojoExecutionException {
  try {
    targetDir.mkdirs();
    FileUtils.cleanDirectory(targetDir);
  } catch (IOException e) {
    throw new MojoExecutionException("Could not prepare targetDirectory for extraction: " + e.getMessage(), e);
  }
}

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

/**
 * Recursively delete a directory.
 */
public static void deleteDirectory( final File directory )
  throws IOException
{
  if ( !directory.exists() )
  {
    return;
  }
  cleanDirectory( directory );
  if ( !directory.delete() )
  {
    final String message = "Directory " + directory + " unable to be deleted.";
    throw new IOException( message );
  }
}

代码示例来源:origin: org.apache.continuum/continuum-purge

private void purgeRepository( String path )
  throws ContinuumPurgeExecutorException
{
  try
  {
    FileUtils.cleanDirectory( path );
  }
  catch ( IOException e )
  {
    throw new ContinuumPurgeExecutorException( "Error while purging all artifacts or directories in " + path,
                          e );
  }
  log.info( ContinuumPurgeConstants.PURGE_REPO_CONTENTS + " - " + path );
}

代码示例来源:origin: org.apache.maven.wagon/wagon-provider-test

public static File createDir( final String name )
  throws IOException
{
  final File baseDirectory = getTestOutputDir();
  final File retValue = new File( baseDirectory, name );
    if ( retValue.exists() )
  {
    FileUtils.cleanDirectory( retValue );
    return retValue;
  }
  
  retValue.mkdirs();
  if ( !retValue.exists() )
  {
    throw new IOException( "Unable to create the directory for testdata " + retValue.getPath() );
  }
  return retValue;
}

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

public static File createDir( final String name )
  throws IOException
{
  final File baseDirectory = getTestOutputDir();
  final File retValue = new File( baseDirectory, name );
    if ( retValue.exists() )
  {
    FileUtils.cleanDirectory( retValue );
    return retValue;
  }
  
  retValue.mkdirs();
  if ( !retValue.exists() )
  {
    throw new IOException( "Unable to create the directory for testdata " + retValue.getPath() );
  }
  return retValue;
}

代码示例来源:origin: org.apache.continuum/continuum-purge

private void purgeBuildOutput( String path )
    throws ContinuumPurgeExecutorException
  {
    File buildOutputDir = new File( path );

    FileFilter filter = DirectoryFileFilter.DIRECTORY;

    File[] projectsDir = buildOutputDir.listFiles( filter );

    try
    {
      for ( File projectDir : projectsDir )
      {
        FileUtils.cleanDirectory( projectDir );
        log.info( ContinuumPurgeConstants.PURGE_DIR_CONTENTS + " - " + projectDir.getName() );
      }
    }
    catch ( IOException e )
    {
      throw new ContinuumPurgeExecutorException( "Error while purging all buildOutput directories", e );
    }
  }
}

代码示例来源:origin: raydac/mvn-golang

private void cleanGoPath() throws MojoFailureException {
 try {
  final File[] goPathFolders = findGoPath(false);
  for (final File f : goPathFolders) {
   if (f.isDirectory()) {
    getLog().warn("Cleaning the Go Path folder : " + f);
    FileUtils.cleanDirectory(f);
   } else {
    getLog().info("Can't find GOPATH folder : " + f);
   }
  }
 } catch (IOException ex) {
  throw new MojoFailureException("Can't clean the Go Path folder", ex);
 }
}

代码示例来源:origin: org.codehaus.mojo/rpm-maven-plugin

FileUtils.cleanDirectory( dir );

代码示例来源:origin: dtrott/maven-thrift-plugin

cleanDirectory(temporaryThriftFileDirectory);

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

/**
   * {@inheritDoc}
   */
  public void closeConnection() throws ConnectionException {

    log.debug("Invoked closeConnection()");

    try {

      git.pushAll(skipEmptyCommit);

      if (safeCheckout)
        FileUtils.cleanDirectory(git.workDir);

    } catch (Exception e) {
      throw new ConnectionException("Unable to push git repostory: " + e.getMessage(), e);
    }
  }
}

代码示例来源:origin: mojohaus/rpm-maven-plugin

FileUtils.cleanDirectory( dir );

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

FileUtils.cleanDirectory(workDir);

代码示例来源:origin: dtrott/maven-thrift-plugin

cleanDirectory(outputDirectory);

代码示例来源:origin: org.sonatype.spice/spice-timeline

FileUtils.cleanDirectory( configuration.getIndexDirectory() );

代码示例来源:origin: khuxtable/wagon-gitsite

FileUtils.cleanDirectory(fileSet.getBasedir());
} catch (IOException e) {
  return new CheckOutScmResult("clean directory", "The directory cleanup failed.", e.getMessage(), false);

相关文章