mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
e94a48ffc8
Partially addresses #11581 Signed-off-by: Ankush Agarwal <ankushagarwal11@gmail.com>
28 lines
574 B
Go
28 lines
574 B
Go
package system
|
|
|
|
import (
|
|
"syscall"
|
|
)
|
|
|
|
// fromStatT converts a syscall.Stat_t type to a system.Stat_t type
|
|
func fromStatT(s *syscall.Stat_t) (*Stat_t, error) {
|
|
return &Stat_t{size: s.Size,
|
|
mode: s.Mode,
|
|
uid: s.Uid,
|
|
gid: s.Gid,
|
|
rdev: s.Rdev,
|
|
mtim: s.Mtim}, nil
|
|
}
|
|
|
|
// Stat takes a path to a file and returns
|
|
// a system.Stat_t type pertaining to that file.
|
|
//
|
|
// Throws an error if the file does not exist
|
|
func Stat(path string) (*Stat_t, error) {
|
|
s := &syscall.Stat_t{}
|
|
err := syscall.Stat(path, s)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return fromStatT(s)
|
|
}
|