afero icon indicating copy to clipboard operation
afero copied to clipboard

Add Chmod() method to File

Open owbone opened this issue 2 years ago • 1 comments

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.

owbone avatar May 20 '22 11:05 owbone

CLA assistant check
All committers have signed the CLA.

CLAassistant avatar May 20 '22 11:05 CLAassistant