* The backing map is protected by a RWMutex
* This commit double checks for the existence of the directory inside the write lock to avoid potential data races when multiple goroutines tries to create
the same directory.
Fixes#361Fixes#298
We recently added a check for fs.ReadDirFile in IOFS.ReadDir, but forgot to apply a sort to the
result as defined in the spec.
This fixes that and adds a test case for it.
And implement `fs.ReadDirFile` for `BasePathFile`.
There are other `File` implementations that could also benefit from the above, but
this is a start.
The primary motivation behind this is to allow `fs.WalkDir` use the native
implementation whenever possible, as that new function was added in Go 1.16 with
speed as its main selling point.
This commit also adds a benchmark for `fs.WalkDir` that, when compared to the main branch:
```bash
name old time/op new time/op delta
WalkDir-10 369µs ± 1% 196µs ± 3% -46.89% (p=0.029 n=4+4)
name old alloc/op new alloc/op delta
WalkDir-10 85.3kB ± 0% 40.2kB ± 0% -52.87% (p=0.029 n=4+4)
name old allocs/op new allocs/op delta
WalkDir-10 826 ± 0% 584 ± 0% -29.30% (p=0.029 n=4+4)
```
Fixes#365
As explained in
https://github.com/spf13/afero/pull/291#issuecomment-807324649, now that
`afero` supports `io/fs.FS`, it requires `go` >= `1.15.10`.
Rather than pinning to `1.15` and occasionally confusing users who are
on < `1.15.10`, I thought simplest to jump straight to `1.16`.
Especially given `1.18` was just released, the upstream `go` team no
longer even supports `1.16`.
The change to `go.sum` was the result of running `go mod tidy`.
github.com/pkg/sftp to v1.13.1 (this fixes a security vulnerability)
golang.org/x/crypto to v0.0.0-20211108221036-ceb1ce70b4fa
golang.org/x/text to v0.3.7
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.