You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Paul King (JIRA)" <ji...@apache.org> on 2018/03/06 23:26:13 UTC
[jira] [Closed] (GROOVY-8341) GDK: eachDirRecurse and
eachFileRecurse are NOT depth-first
[ https://issues.apache.org/jira/browse/GROOVY-8341?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Paul King closed GROOVY-8341.
-----------------------------
> 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
> Assignee: Paul King
> Priority: Minor
> Fix For: 2.4.13
>
>
> 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
(v7.6.3#76005)