groovy
  1. groovy
  2. GROOVY-403

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

    Details

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

      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 made changes -
        Field Original Value New Value
        Fix Version/s 1.0-rc1 [ 10510 ]
        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() }
        Guillaume Laforge made changes -
        Resolution Fixed [ 1 ]
        Status Open [ 1 ] Resolved [ 5 ]
        Paul King made changes -
        Status Resolved [ 5 ] Closed [ 6 ]

          People

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

            Dates

            • Created:
              Updated:
              Resolved: