Skip to content

Managing file permissions when writing files #4

Open
Lambourl wants to merge 3 commits intomasterfrom
feature/modify-permission-on-a-create-file
Open

Managing file permissions when writing files #4
Lambourl wants to merge 3 commits intomasterfrom
feature/modify-permission-on-a-create-file

Conversation

@Lambourl
Copy link

@Lambourl Lambourl commented Sep 9, 2025

The purpose of this program is to be able to manage the writing or modification of content while simultaneously managing file permissions.

- Added two new from_string overloads to allow writing file contents while setting explicit boost::filesystem::perms
- Ensures callers can both write file content and control file permissions in one operation.
- Maintains consistency with existing from_string API by providing both error-code and exception-throwing variants.
Comment on lines +94 to +97
inline void from_string(const std::string &path, const std::string &content, std::error_condition &ec,const boost::filesystem::perms& perms, boost::system::error_code& ec_perms) {
from_string(path, content, ec);
boost::filesystem::permissions(path, perms, ec_perms);
}
Copy link
Contributor

@daminetreg daminetreg Sep 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it's a great idea to have 2 error code types, we should at least stanrdadize on the same type, that there are 2 parameters : why not. But it would be better there would be only one holding both codes and the function could just return early on error.

- return earlier in case of write error
Copy link
Contributor

@daminetreg daminetreg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here one thing that I dislike about these abstractions is that they don't write directly with the provided permissions. They write with whatever permissions and then set them afterwards.

I don't know if it's doable otherwise, but that would be my comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants