Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-1605

Have a delete() method in File that deletes all subdirectories and contained files

Attach filesAttach ScreenshotVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • New Feature
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 1.1-beta-2
    • 1.6-rc-1, 1.5.8, 1.7-beta-1
    • groovy-jdk
    • None
    • all

    Description

      Deleting a directory including all subdirectories is a very tedious task. A method in File like "deleteRecursively()" would really help.

      I am currently using already qutie nice code like this:

      def dataDir = new File( ... path ...)

      def dirs = []

      dataDir.eachFileRecurse {
      if (!it.isDirectory()) log.info("Deleting ${it.name}: ${it.delete()}")
      else dirs << it
      }

      dirs.reverse().each { log.info("Deleting directory: ${it.name}: ${it.delete()}") }

      But why could it not be new File ( ... dir ...).deleteDir() or similar?

      Attachments

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            guillaume Guillaume Sauthier
            hansamann Sven Haiges
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment