Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Chmod() method to File #357

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Add Chmod() method to File #357

wants to merge 1 commit into from

Conversation

owbone
Copy link

@owbone owbone commented May 20, 2022

os.File offers a Chmod() method. This is often safer and more direct
to use than os.Chmod() because it operates on an open file descriptor
rather than having to lookup the file by name. Without this, it's
possible for the target file to be renamed, in which case an
os.Chmod() would either fail or apply to any file that's taken its
place.

Therefore, add the Chmod() method to the File interface, and
implement it for all File implementations. The bulk of this change is
in MemMapFs, which required moving the chmod functionality down into
the mem package so that it can be shared between both mem.File and
MemMapFs.

@CLAassistant
Copy link

CLAassistant commented May 20, 2022

CLA assistant check
All committers have signed the CLA.

`os.File` offers a `Chmod()` method. This is often safer and more direct
to use than `os.Chmod()` because it operates on an open file descriptor
rather than having to lookup the file by name. Without this, it's
possible for the target file to be renamed, in which case an
`os.Chmod()` would either fail or apply to any file that's taken its
place.

Therefore, add the `Chmod()` method to the `File` interface, and
implement it for all `File` implementations. The bulk of this change is
in `MemMapFs`, which required moving the chmod functionality down into
the `mem` package so that it can be shared between both `mem.File` and
`MemMapFs`.
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.

None yet

2 participants