Created
April 26, 2016 07:17
-
-
Save jasperla/b75d6a061e5dfa44d91f60b1e75f0c9b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "io/ioutil" | |
| "os" | |
| "syscall" | |
| "github.com/davecgh/go-spew/spew" | |
| ) | |
| type FileStateOS struct { | |
| Inode uint64 `json:"inode,omitempty"` | |
| Device uint64 `json:"device,omitempty"` | |
| } | |
| // GetOSFileState returns the FileStateOS for non windows systems | |
| func GetOSFileState(info *os.FileInfo) *FileStateOS { | |
| stat := (*(info)).Sys().(*syscall.Stat_t) | |
| spew.Dump(stat.Dev) | |
| // Convert inode and dev to uint64 to be cross platform compatible | |
| fileState := &FileStateOS{ | |
| Inode: uint64(stat.Ino), | |
| Device: uint64(stat.Dev), | |
| } | |
| spew.Dump(fileState.Device) | |
| return fileState | |
| } | |
| func main() { | |
| file, _ := ioutil.TempFile("", "") | |
| fileinfo, _ := file.Stat() | |
| GetOSFileState(&fileinfo) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment