How to build a full path string (safely) from separate strings?

后端 未结 7 1318
失恋的感觉
失恋的感觉 2020-12-08 12:34

Does C++ have any equivalent to python\'s function os.path.join? Basically, I\'m looking for something that combines two (or more) parts of a file path so that

7条回答
  •  余生分开走
    2020-12-08 13:28

    At least in Unix / Linux, it's always safe to join parts of a path by /, even if some parts of the path already end in /, i.e. root/path is equivalent to root//path.

    In this case, all you really need is to join things on /. That said, I agree with other answers that boost::filesystem is a good choice if it is available to you because it supports multiple platforms.

提交回复
热议问题