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

attributesboostfilesystems

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++)?

Best Answer

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.