2014-02-21 04:12:25 -05:00
|
|
|
package system
|
|
|
|
|
|
|
|
import (
|
|
|
|
"syscall"
|
|
|
|
)
|
|
|
|
|
2015-03-31 04:03:31 -04:00
|
|
|
// fromStatT converts a syscall.Stat_t type to a system.Stat_t type
|
2015-03-11 11:42:49 -04:00
|
|
|
func fromStatT(s *syscall.Stat_t) (*Stat_t, error) {
|
|
|
|
return &Stat_t{size: s.Size,
|
2014-11-13 15:36:05 -05:00
|
|
|
mode: s.Mode,
|
|
|
|
uid: s.Uid,
|
|
|
|
gid: s.Gid,
|
|
|
|
rdev: s.Rdev,
|
|
|
|
mtim: s.Mtim}, nil
|
2014-02-21 04:12:25 -05:00
|
|
|
}
|
2015-03-11 11:42:49 -04:00
|
|
|
|
2015-03-31 04:03:31 -04:00
|
|
|
// 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
|
2015-03-11 11:42:49 -04:00
|
|
|
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)
|
|
|
|
}
|