File Permissions
In the last lesson you must have noticed functions related to file permissions. This lesson will talk about them.
We'll cover the following...
Permission Functions
We have two major functions related to file permissions:
std::filesystem::status()
andstd::filesystem::permissions()
The first one returns file_status
which contains information about the file type and also its permissions.
And you can use the second function to modify the file permissions. For example, to change a file to be read-only.
std::filesystem::perms
File permissions - std::filesystem::perms
- it’s an enum class that represents the following values:
Name | Value (octal) | POSIX macro | Notes |
---|---|---|---|
none | 0000 | There are no permissions set for the file | |
owner_read | 0400 | S_IRUSR |
Read permission, owner |
owner_write | 0200 | S_IWUSR |
Write permission, owner |