Closed mcharsley closed 7 years ago
Would it be possible to have an option to yield directories after their contents.
This might be doable. I think it can be done without any change in memory requirements. It just requires a bit more state shuffling.
That would be useful e.g. for recursively deleting a directory.
Why can't you use std::fs::remove_dir_all
?
That would be useful e.g. for recursively deleting a directory.
Why can't you use std::fs::remove_dir_all https://doc.rust-lang.org/std/fs/fn.remove_dir_all.html?
Because I'm trying to implement "find" in rust. Using walkdir would eliminate an entire module of my code, but the -depth option requires the parent to be processed after the contents.
thanks
Mark
I don't think I'll be doing this any time soon myself, but I'd be happy to review a PR. (My hope is that this is a small change, but if you think it's a large change, I'd like to discuss it in more detail first.)
I didn't see this issue or PR #19, but implemented something similar this morning by storing the DirEntry
s for the "deferred" directories inside the stack_list: DirList
field.
My code visits each directory twice, once before and once after traversing the children:
https://github.com/michaelsproul/walkdir/commit/363c944f8afa8eedc12d2ed2f22cbebc1381655e
There are a bunch of clones that I should remove from my code (by making a common dir: DirEntry
field on DirList
), and it generally needs some polish, but I figured I'd link it to see what you think.
It's certainly conceptually simpler, but as you say still requires a bit of polish. If you folks want to go this route instead then I'm not going to storm off in a huff :-)
I'd advise copying the test stuff out of my pull request though: no point re-implementing that...
Mark
On Tue, Feb 7, 2017 at 4:52 AM, Michael Sproul notifications@github.com wrote:
I didn't see this issue or PR #19 https://github.com/BurntSushi/walkdir/pull/19, but implemented something similar this morning by storing the DirEntrys for the "deferred" directories inside the stack_list: DirList field.
My code visits each directory twice, once before and once after traversing the children:
michaelsproul@363c944 https://github.com/michaelsproul/walkdir/commit/363c944f8afa8eedc12d2ed2f22cbebc1381655e
There are a bunch of clones that I should remove from my code (by making a common dir: DirEntry field on DirList), and it generally needs some polish, but I figured I'd link it to see what you think.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/BurntSushi/walkdir/issues/18#issuecomment-277901304, or mute the thread https://github.com/notifications/unsubscribe-auth/ALbIF4WI75al5yy2aSctUQCP_UOq9Bzqks5rZ_iOgaJpZM4LyiuV .
Hi. Any progress on this?
thanks
Mark
I haven't done anything on it...
According to the docs:
Results are returned in depth first fashion, with directories yielded before their contents
Would it be possible to have an option to yield directories after their contents. That would be useful e.g. for recursively deleting a directory.