BurntSushi / walkdir

Rust library for walking directories recursively.
The Unlicense
1.21k stars 106 forks source link

Ability to deconstruct DirEntry into "parts" #127

Closed Zooce closed 4 years ago

Zooce commented 4 years ago

I need to copy one directory to another, so as a first draft I'm using WalkDir to walk a source directory and copy its files into a destination.

I have the initial source and destination paths so I can do a string replace on all the DirEntry's and do the copy.

So far this works, but there's something about it that just feels a little sketchy, and I'd rather have a way build a path based on the deconstruction each DirEntry into:

Let me know what you think. Thanks!

BurntSushi commented 4 years ago

Seems like you should be able to get all this by using methods on Path. It's not clear to me why they should be provided on DirEntry, especially if they are only useful in niche circumstances.

Zooce commented 4 years ago

Yea, I see what you're saying. Also, I didn't realize Path has a strip_prefix function, which I think is part of what I'm looking for. I'm really just looking for a function to copy a directory from one places to another, but I haven't found a crate for it (at least not one that's actively maintained). I'll close this. Thanks for your time!