runtime/internal/clite/os: fix stat for macOS

This commit is contained in:
visualfc
2025-05-16 20:36:43 +08:00
parent ffc1f712a3
commit c8fb7eafa0
4 changed files with 32 additions and 7 deletions

View File

@@ -87,12 +87,6 @@ func Remove(path *c.Char) c.Int
//go:linkname Rename C.rename
func Rename(oldpath *c.Char, newpath *c.Char) c.Int
//go:linkname Stat C.stat
func Stat(path *c.Char, buf *StatT) c.Int
//go:linkname Lstat C.lstat
func Lstat(path *c.Char, buf *StatT) c.Int
//go:linkname Truncate C.truncate
func Truncate(path *c.Char, length OffT) c.Int
@@ -285,7 +279,7 @@ func Exit(c.Int)
// -----------------------------------------------------------------------------
// Upon successful completion, the value 0 is returned; otherwise the value -1
// Upon successful completion, the value 0 is returned; otherwise the value -1
// is returned and the global variable errno is set to indicate the error.
//
//go:linkname Sysctl C.sysctl

View File

@@ -0,0 +1,16 @@
//go:build !darwin
// +build !darwin
package os
import (
_ "unsafe"
c "github.com/goplus/llgo/runtime/internal/clite"
)
//go:linkname Stat C.stat
func Stat(path *c.Char, buf *StatT) c.Int
//go:linkname Lstat C.lstat
func Lstat(path *c.Char, buf *StatT) c.Int

View File

@@ -0,0 +1,13 @@
package os
import (
_ "unsafe"
c "github.com/goplus/llgo/runtime/internal/clite"
)
//go:linkname Stat C.stat64
func Stat(path *c.Char, buf *StatT) c.Int
//go:linkname Lstat C.lstat64
func Lstat(path *c.Char, buf *StatT) c.Int

View File

@@ -35,6 +35,7 @@ func statNolog(name string) (FileInfo, error) {
if err != nil {
return nil, &PathError{Op: "stat", Path: name, Err: err}
}
fillFileStatFromSys(&fs, name)
return &fs, nil
}
@@ -47,5 +48,6 @@ func lstatNolog(name string) (FileInfo, error) {
if err != nil {
return nil, &PathError{Op: "lstat", Path: name, Err: err}
}
fillFileStatFromSys(&fs, name)
return &fs, nil
}