Search code examples
c++stringurlc++17file-extension

Can std::filesystem::path::extension be used for url?


Could I use std::filesystem::path::extension to extract the extension of a file for which I have an http address in string format? For local path the discussion can be found here

More in general could I use also its siblings methods stem and filename?

If not, is there any reliable alternative than doing it manually as spelled out in the other pre-C++17 answer?


Solution

  • The URL specification does not fit with the filesystem::path generic path specification. URLs can do things that don't work as intended with filesystem::paths. So while it might be able to work in some cases, there is no guarantee that it will work in all of them.