gojs: implements lstat This implements platform.Lstat and uses it in GOOS=js. Notably, directory listings need to run lstat on their entries to get the correct inodes back. In GOOS=js, directories are a fan-out of names, then lstat. This also fixes stat for inodes on directories. We were missing a test so we didn't know it was broken on windows. The approach used now is reliable on go 1.20, and we should suggest anyone using windows to compile with go 1.20. Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
38 lines
800 B
Go
38 lines
800 B
Go
//go:build (!((amd64 || arm64 || riscv64) && linux) && !((amd64 || arm64) && (darwin || freebsd)) && !((amd64 || arm64) && windows)) || js
|
|
|
|
package platform
|
|
|
|
import (
|
|
"io/fs"
|
|
"os"
|
|
)
|
|
|
|
func lstat(path string, st *Stat_t) (err error) {
|
|
t, err := os.Lstat(path)
|
|
if err = UnwrapOSError(err); err == nil {
|
|
fillStatFromFileInfo(st, t)
|
|
}
|
|
return
|
|
}
|
|
|
|
func stat(path string, st *Stat_t) (err error) {
|
|
t, err := os.Stat(path)
|
|
if err = UnwrapOSError(err); err == nil {
|
|
fillStatFromFileInfo(st, t)
|
|
}
|
|
return
|
|
}
|
|
|
|
func statFile(f fs.File, st *Stat_t) error {
|
|
return defaultStatFile(f, st)
|
|
}
|
|
|
|
func fillStatFromFileInfo(st *Stat_t, t fs.FileInfo) {
|
|
fillStatFromDefaultFileInfo(st, t)
|
|
}
|
|
|
|
func fillStatFromOpenFile(st *Stat_t, fd uintptr, t os.FileInfo) (err error) {
|
|
fillStatFromFileInfo(st, t)
|
|
return
|
|
}
|