Groovy
  1. Groovy
  2. GROOVY-403

allow easier recursive file processing with File.eachFileRecurse { ... }

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.0-beta-5
    • Component/s: None
    • Labels:
      None

      Description

      There's an interesting discussion here...

      http://wiki.codehaus.org/groovy/FileSupport

      one thought was recursive deletion...

      def recursiveDelete(File file) {
      outer = this
      if( file.isDirectory() ) {
      file.eachFile

      { outer.recursiveDelete(it) }

      }

      file.delete()
      }

      I wondered if we should have a recursive file method where you could do

      new File("/home/foo").eachFileRecurse

      { println it.name }

      which would iterate through all files recursively like the above - calling children first before parents.

      Then a recursive delete would be

      file.eachFileRecurse

      { it.delete() }

        Activity

        james strachan created issue -
        james strachan made changes -
        Field Original Value New Value
        Description There's an interesting discussion here...

        http://wiki.codehaus.org/groovy/FileSupport

        one thought was recursive deletion...

        def recursiveDelete(File file) {
            outer = this
            if( file.isDirectory() ) {
                file.eachFile { outer.recursiveDelete(it) }
            }

            file.delete()
        }

        I wondered if we should have a recursive file method where you could do

        new File("/home/foo").eachFileRecurse { println it.name }

        which would iterate through all files recursively like the above - calling children first before parents.

        Then a recursive delete would be

        file.eachFileRecurse { it.delete() }
        There's an interesting discussion here...

        http://wiki.codehaus.org/groovy/FileSupport

        one thought was recursive deletion...

        def recursiveDelete(File file) {
            outer = this
            if( file.isDirectory() ) {
                file.eachFile { outer.recursiveDelete(it) }
            }

            file.delete()
        }

        I wondered if we should have a recursive file method where you could do

        new File("/home/foo").eachFileRecurse { println it.name }

        which would iterate through all files recursively like the above - calling children first before parents.

        Then a recursive delete would be

        file.eachFileRecurse { it.delete() }
        Fix Version/s 1.0-rc1 [ 10510 ]
        Guillaume Delcroix made changes -
        Resolution Fixed [ 1 ]
        Status Open [ 1 ] Resolved [ 5 ]
        Paul King made changes -
        Status Resolved [ 5 ] Closed [ 6 ]
        Mark Thomas made changes -
        Project Import Sun Apr 05 13:32:57 UTC 2015 [ 1428240777691 ]
        Mark Thomas made changes -
        Workflow jira [ 12729560 ] Default workflow, editable Closed status [ 12741589 ]
        Mark Thomas made changes -
        Project Import Mon Apr 06 02:11:23 UTC 2015 [ 1428286283443 ]
        Mark Thomas made changes -
        Workflow jira [ 12968156 ] Default workflow, editable Closed status [ 12975908 ]

          People

          • Assignee:
            Guillaume Delcroix
            Reporter:
            james strachan
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development