-1

I have a path composed of some parts that end up containing special path parts /../../ and to the right side some hypothetical parts. To left of the special parts the path can evaluate to a real path. According to reference the hypothetical parts should be ok and not an issue in itself.

When passed to std::filesystem::weakly_canonical it fails due to being an invalid path (and not just a non-existent file/folder which should be ok). I guess this is because of the special parts .. mentioned.

Is there anything I can call before passing to weakly_canonical to get the special parts handled ?

In reality i want to call std::filesystem::make_relative against another path - which in turn calls weakly_canonical on the input.

darune
  • 10,480
  • 2
  • 24
  • 62

1 Answers1

0

It turned out this was due to the path being hypothetical after all (which could be a bug (?) ). I found out the solution was right in front of me, namely that std::filesystem::path has a function called lexically_relative which as the name implies doesn't use external calls.

darune
  • 10,480
  • 2
  • 24
  • 62