开发者

Getting a file path relative to a particular directory

开发者 https://www.devze.com 2022-12-10 16:53 出处:网络
开发者_StackOverflow社区Is there a nice way in the WinAPI to get a path relative to another path?For example:

开发者_StackOverflow社区Is there a nice way in the WinAPI to get a path relative to another path? For example:

Have a list of paths relative to:

a\b\c\d

And I'd like to change them all to paths relative to

a\b\c

Is there a neat way to do this or should I get path parsing?


As far as i know there is no such functionality in the windows API, but there is e.g. an article on CodeGuru that provides that functionality.

edit:
I stand corrected, there is PathRelativePathTo() in the shell api as mentioned in this answer.


I don't know of any way of doing this directly, but you might be able to do it in a couple of steps using PathCommonPrefix and PathCombine. Otherwise, boost::filesystem may make it possible, eg with the relative_path() method.

0

精彩评论

暂无评论...
验证码 换一张
取 消