hudson.Util.deleteContentsRecursive()方法的使用及代码示例

x33g5p2x  于2022-01-31 转载在 其他  
字(6.6k)|赞(0)|评价(0)|浏览(219)

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

Util.deleteContentsRecursive介绍

[英]Deletes the contents of the given directory (but not the directory itself) recursively. It does not take no for an answer - if necessary, it will have multiple attempts at deleting things.
[中]

代码示例

代码示例来源:origin: jenkinsci/jenkins

@Override
  public Void invoke(File f, VirtualChannel channel) throws IOException {
    Util.deleteContentsRecursive(fileToPath(f), path -> deleting(path.toFile()));
    return null;
  }
}

代码示例来源:origin: jenkinsci/jenkins

/**
 * Deletes the contents of the given directory (but not the directory itself)
 * recursively.
 * It does not take no for an answer - if necessary, it will have multiple
 * attempts at deleting things.
 *
 * @throws IOException
 *      if the operation fails.
 */
public static void deleteContentsRecursive(@Nonnull File file) throws IOException {
  deleteContentsRecursive(fileToPath(file), PathRemover.PathChecker.ALLOW_ALL);
}

代码示例来源:origin: org.eclipse.hudson/hudson-core

public Void invoke(File f, VirtualChannel channel) throws IOException {
    Util.deleteContentsRecursive(f);
    return null;
  }
});

代码示例来源:origin: hudson/hudson-2.x

public Void invoke(File f, VirtualChannel channel) throws IOException {
    Util.deleteContentsRecursive(f);
    return null;
  }
});

代码示例来源:origin: org.jvnet.hudson.main/hudson-core

public Void invoke(File f, VirtualChannel channel) throws IOException {
    Util.deleteContentsRecursive(f);
    return null;
  }
});

代码示例来源:origin: org.eclipse.hudson.main/hudson-core

public Void invoke(File f, VirtualChannel channel) throws IOException {
    Util.deleteContentsRecursive(f);
    return null;
  }
});

代码示例来源:origin: org.jvnet.hudson.plugins/subversion

/**
   * Cleans workspace.
   *
   * @throws IOException IOException
   */
  protected void cleanupBeforeCheckout() throws IOException {
    if (listener != null && listener.getLogger() != null) {
      listener.getLogger().println("Cleaning workspace " + ws.getCanonicalPath());
    }
    Util.deleteContentsRecursive(ws);
  }
}

代码示例来源:origin: org.hudsonci.plugins/subversion

/**
   * Cleans workspace.
   *
   * @throws IOException IOException
   */
  protected void cleanupBeforeCheckout() throws IOException {
    if (listener != null && listener.getLogger() != null) {
      listener.getLogger().println("Cleaning workspace " + ws.getCanonicalPath());
    }
    Util.deleteContentsRecursive(ws);
  }
}

代码示例来源:origin: org.eclipse.hudson.main/hudson-core

/**
 * Deletes this build's artifacts. 
 *
 * @throws IOException
 *      if we fail to delete.
 *
 * @since 1.350
 */
public synchronized void deleteArtifacts() throws IOException {
  File artifactsDir = getArtifactsDir();
  Util.deleteContentsRecursive(artifactsDir);
}

代码示例来源:origin: hudson/hudson-2.x

/**
 * Deletes this build's artifacts. 
 *
 * @throws IOException
 *      if we fail to delete.
 *
 * @since 1.350
 */
public synchronized void deleteArtifacts() throws IOException {
  File artifactsDir = getArtifactsDir();
  Util.deleteContentsRecursive(artifactsDir);
}

代码示例来源:origin: org.jvnet.hudson.main/hudson-core

/**
 * Deletes this build's artifacts. 
 *
 * @throws IOException
 *      if we fail to delete.
 *
 * @since 1.350
 */
public synchronized void deleteArtifacts() throws IOException {
  File artifactsDir = getArtifactsDir();
  Util.deleteContentsRecursive(artifactsDir);
}

代码示例来源:origin: org.eclipse.hudson/hudson-core

/**
 * Deletes this build's artifacts.
 *
 * @throws IOException if we fail to delete.
 *
 * @since 1.350
 */
public synchronized void deleteArtifacts() throws IOException {
  File artifactsDir = getArtifactsDir();
  Util.deleteContentsRecursive(artifactsDir);
}

代码示例来源:origin: org.jvnet.hudson.plugins/subversion

/**
   * Cleans workspace.
   *
   * @throws java.io.IOException IOException
   */
  protected void cleanupBeforeCheckout() throws IOException {
    for (final SubversionSCM.ModuleLocation location : locations) {
      File local = new File(ws, location.getLocalDir());
      if (listener != null && listener.getLogger() != null) {
        listener.getLogger().println("Cleaning checkout folder " + local.getCanonicalPath());
      }
      Util.deleteContentsRecursive(local);
    }
  }
}

代码示例来源:origin: org.hudsonci.plugins/subversion

/**
   * Cleans workspace.
   *
   * @throws java.io.IOException IOException
   */
  protected void cleanupBeforeCheckout() throws IOException {
    for (final SubversionSCM.ModuleLocation location : locations) {
      File local = new File(ws, location.getLocalDir());
      if (listener != null && listener.getLogger() != null) {
        listener.getLogger().println("Cleaning checkout folder " + local.getCanonicalPath());
      }
      Util.deleteContentsRecursive(local);
    }
  }
}

代码示例来源:origin: hudson/hudson-2.x

public static void deleteRecursive(File dir) throws IOException {
  if(!isSymlink(dir))
    deleteContentsRecursive(dir);
  deleteFile(dir);
}

代码示例来源:origin: org.eclipse.hudson/hudson-core

public static void deleteRecursive(File dir) throws IOException {
  if (!isSymlink(dir)) {
    deleteContentsRecursive(dir);
  }
  deleteFile(dir);
}

代码示例来源:origin: org.eclipse.hudson.main/hudson-core

public static void deleteRecursive(File dir) throws IOException {
  if (!isSymlink(dir)) {
    deleteContentsRecursive(dir);
  }
  deleteFile(dir);
}

代码示例来源:origin: org.jvnet.hudson.main/hudson-core

public static void deleteRecursive(File dir) throws IOException {
  if(!isSymlink(dir))
    deleteContentsRecursive(dir);
  deleteFile(dir);
}

代码示例来源:origin: org.eclipse.hudson.main/hudson-core

/**
 * Explodes the plugin into a directory, if necessary.
 */
private static void explode(File archive, File destDir) throws IOException {
  if(!destDir.exists())
    destDir.mkdirs();
  // timestamp check
  File explodeTime = new File(destDir,".timestamp");
  if(explodeTime.exists() && explodeTime.lastModified()==archive.lastModified())
    return; // no need to expand
  // delete the contents so that old files won't interfere with new files
  Util.deleteContentsRecursive(destDir);
  try {
    Expand e = new Expand();
    e.setProject(new Project());
    e.setTaskType("unzip");
    e.setSrc(archive);
    e.setDest(destDir);
    e.execute();
  } catch (BuildException x) {
    throw new IOException2("Failed to expand " + archive,x);
  }
  try {
    new FilePath(explodeTime).touch(archive.lastModified());
  } catch (InterruptedException e) {
    throw new AssertionError(e); // impossible
  }
}

代码示例来源:origin: org.eclipse.hudson/hudson-core

public void deleteTeam(String teamName, boolean deleteJobs) throws TeamNotFoundException, IOException {
  Team team = findTeam(teamName);
  if (Team.PUBLIC_TEAM_NAME.equals(team.getName())) {
    throw new IOException("Cannot delete public team");
  }
  for (TeamJob job : team.getJobs()) {
    TopLevelItem item = Hudson.getInstance().getItem(job.getId());
    if (item != null && (item instanceof Job)) {
      if (deleteJobs) {
        try {
          item.delete();
        } catch (InterruptedException e) {
          throw new IOException("Delete team " + team.getName() + " was interrupted");
        }
      } else {
        // Make deleted team jobs public
        moveJob((Job) item, team, publicTeam, null);
      }
    }
  }
  teams.remove(team);
  save();
  File teamFolder = team.getTeamFolder(teamsFolder);
  if (teamFolder.exists() && teamFolder.isDirectory()) {
    Util.deleteContentsRecursive(teamFolder);
    Util.deleteFile(teamFolder);
  }
}

相关文章