Details
-
Type:
Improvement
-
Status:
Closed
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: None
-
Fix Version/s: 1.0-beta-5
-
Component/s: None
-
Labels:None
-
Number of attachments :
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
}
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() }
I've implemented eachFileRecurse() which recursively explores a directory structure, in depth first, including the directories in the search. But the directory is returned first before its children. Perhaps we should have two different methods ? one returning the directory first, the other including it after the subdirectories and files are explored ?