1

Say we have a filesystem::path pointing at a directory /fo/bar/.

How do i best get a path pointing to /fo?

Note: The path::parent_path() is not sufficient here. It does only go back to the directory, but if the path is already pointing at a directory it does nothing.

Note2: It seems like my problem was something like leaving a slash in the pathname, when trying without it works as expected. Nice.

Lasersköld
  • 2,028
  • 14
  • 20
  • [I can't reproduce your behaviour.](http://coliru.stacked-crooked.com/a/2953472c2e1bcf5b) I clearly have it pointing to a directory and it still returns the parent path. In addition, I don't understand your iterator point—path iterators model input iterators (and more in fact). – chris Jun 05 '20 at 06:38
  • Wierd.. You're right. It does work. I tried it again and again, but apparently i did something wrong. – Lasersköld Jun 05 '20 at 06:45
  • Ok, so like in the duplicate i must have hade a trailing slash in the pathname. – Lasersköld Jun 05 '20 at 06:54

0 Answers0