如何使用Boost库更改文件权限?

mos*_*osg 4 c++ permissions boost boost-filesystem

如何使用Boost库将文件的权限更改为只读?

我已经看过一些问题,比如这个这个,但我还是不知道该怎么做,我试过做

boost::filesystem::wpath path = L"abc.txt";
if( boost::filesystem::exists( path ) && boost::filesystem::is_regular_file( path ) )
{
    boost::filesystem::file_status s = boost::filesystem::status( path );
    /* here I need to set file permissitons to READ ONLY for `path` file */
}
Run Code Online (Sandbox Code Playgroud)

有任何想法吗?

Igo*_* R. 7

#include <boost/filesystem.hpp>

int main()
{
  using namespace boost::filesystem;
  wpath path = L"abc.txt";
  permissions(path, others_read|owner_read);
}
Run Code Online (Sandbox Code Playgroud)


kor*_*bes 7

使用boost 1.55,在Windows下,以下工作:

permissions(file_path, add_perms|owner_write|group_write|others_write);
Run Code Online (Sandbox Code Playgroud)