Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can boost filesystem change the read-only attribute of a file?

Is there a way to change the attribute of a file from read-only to read-write using the boost filesystem library? If not, what is the next-best way to do this on Windows (using Microsoft's C++)?

like image 488
Brian Stewart Avatar asked Nov 18 '09 23:11

Brian Stewart


2 Answers

I didn't find how to do that in the boost library. But you can do it using Windows API:

SetFileAttributes(lpFileName, GetFileAttributes(lpFileName) & ~FILE_ATTRIBUTE_READONLY);

See SetFileAttributes Function and GetFileAttributes Function for more info.

like image 110
Sergey Podobry Avatar answered Oct 19 '22 23:10

Sergey Podobry


The following worked with Boost 1.55 on Windows:

permissions(file_path, add_perms|owner_write|group_write|others_write);
like image 30
korbes Avatar answered Oct 19 '22 23:10

korbes