Commit Graph

8 Commits

Author SHA1 Message Date
re 1707ad0dd8 fix repos 2022-12-12 18:01:24 +03:00
Bjørn Erik Pedersen 2a70f2bb2d Make mem.File implement fs.ReadDirFile 2022-07-19 12:29:51 +02:00
Bjørn Erik Pedersen 0aa65edf44 Fix sorting in IOFS.ReadDir
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.
2022-07-19 11:13:10 +02:00
Bjørn Erik Pedersen c92ae364de Make IOFS.ReadDir check for fs.ReadDirFile
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
2022-07-14 15:11:09 +02:00
Bjørn Erik Pedersen 939bf3d6b2 Fix test failures on Windows
And also enable the CI build for Windows.
2022-07-14 13:05:08 +02:00
Bjørn Erik Pedersen 9439436a4d all: Run gofmt -s -w 2022-07-14 13:05:08 +02: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