| 1 | // Copyright 2022 The Go Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style |
| 3 | // license that can be found in the LICENSE file. |
| 4 | |
| 5 | //go:build !windows && !plan9 |
| 6 | |
| 7 | package robustio |
| 8 | |
| 9 | import ( |
| 10 | "os" |
| 11 | "syscall" |
| 12 | "time" |
| 13 | ) |
| 14 | |
| 15 | func getFileID(filename string) (FileID, time.Time, error) { |
| 16 | fi, err := os.Stat(filename) |
| 17 | if err != nil { |
| 18 | return FileID{}, time.Time{}, err |
| 19 | } |
| 20 | stat := fi.Sys().(*syscall.Stat_t) |
| 21 | return FileID{ |
| 22 | device: uint64(stat.Dev), // (int32 on darwin, uint64 on linux) |
| 23 | inode: stat.Ino, |
| 24 | }, fi.ModTime(), nil |
| 25 | } |