Closed Zooce closed 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.
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!
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:WalkDir
) :entry?.root()
DirEntry
is, minus the root :entry?.stem()
orentry?.trunk()
orentry?.branch()
(going with the tree verbiage here - doesn't really matter)entry?.leaf()
althoughentry?.file_name()
already satisfies thisLet me know what you think. Thanks!