Commit Graph

3 Commits

Author SHA1 Message Date
Oliver Bone 428eac8624
Add Chmod() method to File
`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`.
2022-05-20 14:02:18 +01:00
Vladimir Stolyarov 164e24d3b1
Add reverse wrapper from io.FS to afero.Fs
afero.Fs/File requires mutating methods implementation but they will always return error because fs.FS is read-only.
ReadAt and Seek will return error if underlying fs.File doesn't implement them.
2021-03-13 22:50:37 +03:00
Vladimir Stolyarov c597fe5aa8
Add adapter to allow afero.Fs usage as io/fs.FS
It will not affect users of go older than 1.16 because files with `io/fs` import marked with build constraints
2021-03-13 21:09:09 +03:00