mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
844538142d
Signed-off-by: Antonio Murdaca <me@runcom.ninja>
27 lines
574 B
Go
27 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{}
|
|
if err := syscall.Stat(path, s); err != nil {
|
|
return nil, err
|
|
}
|
|
return fromStatT(s)
|
|
}
|