Signed-off-by: Ivan Markin <twim@riseup.net>
| ... | ... |
@@ -13,3 +13,15 @@ func fromStatT(s *syscall.Stat_t) (*StatT, error) {
|
| 13 | 13 |
rdev: uint64(s.Rdev), |
| 14 | 14 |
mtim: s.Mtim}, nil |
| 15 | 15 |
} |
| 16 |
+ |
|
| 17 |
+// Stat takes a path to a file and returns |
|
| 18 |
+// a system.Stat_t type pertaining to that file. |
|
| 19 |
+// |
|
| 20 |
+// Throws an error if the file does not exist |
|
| 21 |
+func Stat(path string) (*StatT, error) {
|
|
| 22 |
+ s := &syscall.Stat_t{}
|
|
| 23 |
+ if err := syscall.Stat(path, s); err != nil {
|
|
| 24 |
+ return nil, err |
|
| 25 |
+ } |
|
| 26 |
+ return fromStatT(s) |
|
| 27 |
+} |