sysfs: adds FS.Stat and companions in platform (#1140)
This centralizes filestat logic by making our own `Stat_t` similar to `syscall.Stat_t`. This exposes utilities in the platform package and adds a new function `FS.Stat` which avoids having to use `fs.File` to get the same info. Doing so at the FS abstraction allows us to optimize how it is implemented internally using portable means (e.g. `os.StatFile`) or OS-specific means where necessary, e.g. in windows. This also ensures `platform.OpenFile` returns syscall.Errno and centralizes error checking with a new `require.EqualErrno` test. Signed-off-by: Adrian Cole <adrian@tetrate.io>
This commit is contained in:
@@ -5,6 +5,8 @@ import (
|
||||
"io/fs"
|
||||
"os"
|
||||
"syscall"
|
||||
|
||||
"github.com/tetratelabs/wazero/internal/platform"
|
||||
)
|
||||
|
||||
// NewReadFS is used to mask an existing FS for reads. Notably, this allows
|
||||
@@ -125,3 +127,8 @@ func maskForReads(f fs.File) fs.File {
|
||||
panic("BUG: unhandled pattern")
|
||||
}
|
||||
}
|
||||
|
||||
// Stat implements FS.Stat
|
||||
func (r *readFS) Stat(path string, stat *platform.Stat_t) error {
|
||||
return r.fs.Stat(path, stat)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user