golang.org/x/tools@v0.21.1-0.20240520172518-788d39e776b1/internal/robustio/robustio_plan9.go (about)

     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 plan9
     6  // +build plan9
     7  
     8  package robustio
     9  
    10  import (
    11  	"os"
    12  	"syscall"
    13  	"time"
    14  )
    15  
    16  func getFileID(filename string) (FileID, time.Time, error) {
    17  	fi, err := os.Stat(filename)
    18  	if err != nil {
    19  		return FileID{}, time.Time{}, err
    20  	}
    21  	dir := fi.Sys().(*syscall.Dir)
    22  	return FileID{
    23  		device: uint64(dir.Type)<<32 | uint64(dir.Dev),
    24  		inode:  dir.Qid.Path,
    25  	}, fi.ModTime(), nil
    26  }