[
https://issues.apache.org/jira/browse/GROOVY-8341?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Dirk Heinrichs updated GROOVY-8341:
-----------------------------------
Description:
The documentation for those two methods states: "Sub-directories are
recursively searched in a depth-first fashion." But the result is NOT
depth-first, as the following example shows:
Given a directory tree of {code}/tmp
|-/foo
| |-/bar
| |-/foo
| |-/bar
| |-/baz
|-/baz{code}
the following simple code {code}#!/usr/bin/groovy
File rootDir = new File(new URI('file:/tmp/foo'))
rootDir.eachDirRecurse {
println(it)
}{code}
gives this result {code}/tmp/foo/bar
/tmp/foo/bar/baz
/tmp/foo/bar/foo
/tmp/foo/bar/bar
/tmp/foo/baz{code}
while {code}% find /tmp/foo -depth -type d{code}
correctly gives {code}/tmp/foo/bar/baz
/tmp/foo/bar/foo
/tmp/foo/bar/bar
/tmp/foo/bar
/tmp/foo/baz
/tmp/foo{code}
was:
The documentation for those two methods states: "Sub-directories are
recursively searched in a depth-first fashion." But the result is NOT
depth-first, as the following example shows:
Given a directory tree of {code}/tmp
|-/foo
| |-/foo
| |-/bar
| |-/baz
|-/baz{code}
the following simple code {code}#!/usr/bin/groovy
File rootDir = new File(new URI('file:/tmp/foo'))
rootDir.eachDirRecurse {
println(it)
}{code}
gives this result {code}/tmp/foo/bar
/tmp/foo/bar/baz
/tmp/foo/bar/foo
/tmp/foo/bar/bar
/tmp/foo/baz{code}
while {code}% find /tmp/foo -depth -type d{code}
correctly gives {code}/tmp/foo/bar/baz
/tmp/foo/bar/foo
/tmp/foo/bar/bar
/tmp/foo/bar
/tmp/foo/baz
/tmp/foo{code}
> GDK: eachDirRecurse and eachFileRecurse are NOT depth-first
> -----------------------------------------------------------
>
> Key: GROOVY-8341
> URL: https://issues.apache.org/jira/browse/GROOVY-8341
> Project: Groovy
> Issue Type: Bug
> Components: groovy-jdk
> Affects Versions: 2.4.11
> Environment: Windows Linux
> Reporter: Dirk Heinrichs
> Priority: Minor
>
> The documentation for those two methods states: "Sub-directories are
> recursively searched in a depth-first fashion." But the result is NOT
> depth-first, as the following example shows:
> Given a directory tree of {code}/tmp
> |-/foo
> | |-/bar
> | |-/foo
> | |-/bar
> | |-/baz
> |-/baz{code}
> the following simple code {code}#!/usr/bin/groovy
> File rootDir = new File(new URI('file:/tmp/foo'))
> rootDir.eachDirRecurse {
> println(it)
> }{code}
> gives this result {code}/tmp/foo/bar
> /tmp/foo/bar/baz
> /tmp/foo/bar/foo
> /tmp/foo/bar/bar
> /tmp/foo/baz{code}
> while {code}% find /tmp/foo -depth -type d{code}
> correctly gives {code}/tmp/foo/bar/baz
> /tmp/foo/bar/foo
> /tmp/foo/bar/bar
> /tmp/foo/bar
> /tmp/foo/baz
> /tmp/foo{code}
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)