Appending to boost::filesystem::path

后端 未结 5 1215
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-02-05 00:53

I have a certain boost::filesystem::path in hand and I\'d like to append a string (or path) to it.

boost::filesystem::path p(\"c:\\\\dir\");
p.appen         


        
5条回答
  •  囚心锁ツ
    2021-02-05 01:48

    If it's really just the file name extension you want to change then you are probably better off writing:

    p.replace_extension(".foo");
    

    for most other file path operations you can use the operators /= and / allowing to concatenate parts of a name. For instance

    boost::filesystem::path p("c:\\dir");
    p /= "subdir";
    

    will refer to c:\dir\subdir.

提交回复
热议问题