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

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

本文整理了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

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

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

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

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

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

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

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

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

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

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

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

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

  1. /**
  2. * Cleans workspace.
  3. *
  4. * @throws IOException IOException
  5. */
  6. protected void cleanupBeforeCheckout() throws IOException {
  7. if (listener != null && listener.getLogger() != null) {
  8. listener.getLogger().println("Cleaning workspace " + ws.getCanonicalPath());
  9. }
  10. Util.deleteContentsRecursive(ws);
  11. }
  12. }

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

  1. /**
  2. * Cleans workspace.
  3. *
  4. * @throws IOException IOException
  5. */
  6. protected void cleanupBeforeCheckout() throws IOException {
  7. if (listener != null && listener.getLogger() != null) {
  8. listener.getLogger().println("Cleaning workspace " + ws.getCanonicalPath());
  9. }
  10. Util.deleteContentsRecursive(ws);
  11. }
  12. }

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

  1. /**
  2. * Deletes this build's artifacts.
  3. *
  4. * @throws IOException
  5. * if we fail to delete.
  6. *
  7. * @since 1.350
  8. */
  9. public synchronized void deleteArtifacts() throws IOException {
  10. File artifactsDir = getArtifactsDir();
  11. Util.deleteContentsRecursive(artifactsDir);
  12. }

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

  1. /**
  2. * Deletes this build's artifacts.
  3. *
  4. * @throws IOException
  5. * if we fail to delete.
  6. *
  7. * @since 1.350
  8. */
  9. public synchronized void deleteArtifacts() throws IOException {
  10. File artifactsDir = getArtifactsDir();
  11. Util.deleteContentsRecursive(artifactsDir);
  12. }

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

  1. /**
  2. * Deletes this build's artifacts.
  3. *
  4. * @throws IOException
  5. * if we fail to delete.
  6. *
  7. * @since 1.350
  8. */
  9. public synchronized void deleteArtifacts() throws IOException {
  10. File artifactsDir = getArtifactsDir();
  11. Util.deleteContentsRecursive(artifactsDir);
  12. }

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

  1. /**
  2. * Deletes this build's artifacts.
  3. *
  4. * @throws IOException if we fail to delete.
  5. *
  6. * @since 1.350
  7. */
  8. public synchronized void deleteArtifacts() throws IOException {
  9. File artifactsDir = getArtifactsDir();
  10. Util.deleteContentsRecursive(artifactsDir);
  11. }

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

  1. /**
  2. * Cleans workspace.
  3. *
  4. * @throws java.io.IOException IOException
  5. */
  6. protected void cleanupBeforeCheckout() throws IOException {
  7. for (final SubversionSCM.ModuleLocation location : locations) {
  8. File local = new File(ws, location.getLocalDir());
  9. if (listener != null && listener.getLogger() != null) {
  10. listener.getLogger().println("Cleaning checkout folder " + local.getCanonicalPath());
  11. }
  12. Util.deleteContentsRecursive(local);
  13. }
  14. }
  15. }

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

  1. /**
  2. * Cleans workspace.
  3. *
  4. * @throws java.io.IOException IOException
  5. */
  6. protected void cleanupBeforeCheckout() throws IOException {
  7. for (final SubversionSCM.ModuleLocation location : locations) {
  8. File local = new File(ws, location.getLocalDir());
  9. if (listener != null && listener.getLogger() != null) {
  10. listener.getLogger().println("Cleaning checkout folder " + local.getCanonicalPath());
  11. }
  12. Util.deleteContentsRecursive(local);
  13. }
  14. }
  15. }

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

  1. public static void deleteRecursive(File dir) throws IOException {
  2. if(!isSymlink(dir))
  3. deleteContentsRecursive(dir);
  4. deleteFile(dir);
  5. }

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

  1. public static void deleteRecursive(File dir) throws IOException {
  2. if (!isSymlink(dir)) {
  3. deleteContentsRecursive(dir);
  4. }
  5. deleteFile(dir);
  6. }

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

  1. public static void deleteRecursive(File dir) throws IOException {
  2. if (!isSymlink(dir)) {
  3. deleteContentsRecursive(dir);
  4. }
  5. deleteFile(dir);
  6. }

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

  1. public static void deleteRecursive(File dir) throws IOException {
  2. if(!isSymlink(dir))
  3. deleteContentsRecursive(dir);
  4. deleteFile(dir);
  5. }

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

  1. /**
  2. * Explodes the plugin into a directory, if necessary.
  3. */
  4. private static void explode(File archive, File destDir) throws IOException {
  5. if(!destDir.exists())
  6. destDir.mkdirs();
  7. // timestamp check
  8. File explodeTime = new File(destDir,".timestamp");
  9. if(explodeTime.exists() && explodeTime.lastModified()==archive.lastModified())
  10. return; // no need to expand
  11. // delete the contents so that old files won't interfere with new files
  12. Util.deleteContentsRecursive(destDir);
  13. try {
  14. Expand e = new Expand();
  15. e.setProject(new Project());
  16. e.setTaskType("unzip");
  17. e.setSrc(archive);
  18. e.setDest(destDir);
  19. e.execute();
  20. } catch (BuildException x) {
  21. throw new IOException2("Failed to expand " + archive,x);
  22. }
  23. try {
  24. new FilePath(explodeTime).touch(archive.lastModified());
  25. } catch (InterruptedException e) {
  26. throw new AssertionError(e); // impossible
  27. }
  28. }

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

  1. public void deleteTeam(String teamName, boolean deleteJobs) throws TeamNotFoundException, IOException {
  2. Team team = findTeam(teamName);
  3. if (Team.PUBLIC_TEAM_NAME.equals(team.getName())) {
  4. throw new IOException("Cannot delete public team");
  5. }
  6. for (TeamJob job : team.getJobs()) {
  7. TopLevelItem item = Hudson.getInstance().getItem(job.getId());
  8. if (item != null && (item instanceof Job)) {
  9. if (deleteJobs) {
  10. try {
  11. item.delete();
  12. } catch (InterruptedException e) {
  13. throw new IOException("Delete team " + team.getName() + " was interrupted");
  14. }
  15. } else {
  16. // Make deleted team jobs public
  17. moveJob((Job) item, team, publicTeam, null);
  18. }
  19. }
  20. }
  21. teams.remove(team);
  22. save();
  23. File teamFolder = team.getTeamFolder(teamsFolder);
  24. if (teamFolder.exists() && teamFolder.isDirectory()) {
  25. Util.deleteContentsRecursive(teamFolder);
  26. Util.deleteFile(teamFolder);
  27. }
  28. }

相关文章