2022-12-17 00:31:15 +03:00
|
|
|
// Copyright 2022 The Go Authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
|
|
|
//go:build !windows && !plan9
|
|
|
|
// +build !windows,!plan9
|
|
|
|
|
|
|
|
package robustio
|
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
|
|
|
"syscall"
|
2023-01-20 00:41:08 +03:00
|
|
|
"time"
|
2022-12-17 00:31:15 +03:00
|
|
|
)
|
|
|
|
|
2023-01-20 00:41:08 +03:00
|
|
|
func getFileID(filename string) (FileID, time.Time, error) {
|
2022-12-17 00:31:15 +03:00
|
|
|
fi, err := os.Stat(filename)
|
|
|
|
if err != nil {
|
2023-01-20 00:41:08 +03:00
|
|
|
return FileID{}, time.Time{}, err
|
2022-12-17 00:31:15 +03:00
|
|
|
}
|
|
|
|
stat := fi.Sys().(*syscall.Stat_t)
|
|
|
|
return FileID{
|
|
|
|
device: uint64(stat.Dev), // (int32 on darwin, uint64 on linux)
|
|
|
|
inode: stat.Ino,
|
2023-01-20 00:41:08 +03:00
|
|
|
}, fi.ModTime(), nil
|
2022-12-17 00:31:15 +03:00
|
|
|
}
|