microsoft / wil

Windows Implementation Library
MIT License
2.57k stars 234 forks source link

Feature request: a path class #456

Open amtopel opened 1 month ago

amtopel commented 1 month ago

I'm not sure if this has been brought up, or if something like this already exists in the library, but I thought it would be very helpful to have a comprehensive "path" class. ATL's CPathT is pretty good, but it would be nice to build on that with additional methods pertaining to PathCreateFromUrl, UrlCreateFromPath, SHGetKnownFolderPath, GetModuleFileName, GetTempPath, etc.

dunhor commented 1 month ago

This has been a longstanding desire of mine. std::filesystem::path is both inefficient and doesn't handle many Win32-isms properly (such as extended length paths) that I've effectively stopped using it. Perhaps one of these days I'll find the time to finish implementing one

jonwis commented 1 month ago

Sure, a reasonable set of helpers around a counted buffer plus use of the PathCch family of APIs?

amtopel commented 1 month ago

Sure, a reasonable set of helpers around a counted buffer plus use of the PathCch family of APIs?

Well that would be good, but then you might as well use ATL's CPathT. My recommendation would be to add functions that are missing from CPathT, like those mentioned above, plus routine things that don't necessarily correspond to a single API function. For example:

I'd share my own code for this stuff (I've created a CPath2), but it's not very professional looking.