Skip to content

Commit

Permalink
test if FileInfo.Sys() returns a *file.FileInfo and use that
Browse files Browse the repository at this point in the history
  • Loading branch information
ozkatz committed Apr 13, 2024
1 parent 0e20378 commit 7bf8f82
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions file/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,11 @@ type FileInfo struct {
Fileid uint64
}

// FileInfoGetter allows os.FileInfo implementations that implement
// the GetFileInfo() method to explicitly return a *FileInfo.
// Useful for explicitly setting a Fileid without having to use the syscall package
type FileInfoGetter interface {
GetFileInfo() *FileInfo
}

// GetInfo extracts some non-standardized items from the result of a Stat call.
func GetInfo(fi os.FileInfo) *FileInfo {
if v, ok := fi.(FileInfoGetter); ok {
return v.GetFileInfo()
sys := fi.Sys()
if v, ok := sys.(*FileInfo); ok {
return v
}
return getOSFileInfo(fi)
}

0 comments on commit 7bf8f82

Please sign in to comment.