@@ -5,29 +5,22 @@ package winio
55import (
66 "os"
77 "runtime"
8- "syscall"
98 "unsafe"
10- )
11-
12- //sys getFileInformationByHandleEx(h syscall.Handle, class uint32, buffer *byte, size uint32) (err error) = GetFileInformationByHandleEx
13- //sys setFileInformationByHandle(h syscall.Handle, class uint32, buffer *byte, size uint32) (err error) = SetFileInformationByHandle
149
15- const (
16- fileBasicInfo = 0
17- fileIDInfo = 0x12
10+ "golang.org/x/sys/windows"
1811)
1912
2013// FileBasicInfo contains file access time and file attributes information.
2114type FileBasicInfo struct {
22- CreationTime , LastAccessTime , LastWriteTime , ChangeTime syscall .Filetime
15+ CreationTime , LastAccessTime , LastWriteTime , ChangeTime windows .Filetime
2316 FileAttributes uint32
2417 pad uint32 // padding
2518}
2619
2720// GetFileBasicInfo retrieves times and attributes for a file.
2821func GetFileBasicInfo (f * os.File ) (* FileBasicInfo , error ) {
2922 bi := & FileBasicInfo {}
30- if err := getFileInformationByHandleEx ( syscall .Handle (f .Fd ()), fileBasicInfo , (* byte )(unsafe .Pointer (bi )), uint32 (unsafe .Sizeof (* bi ))); err != nil {
23+ if err := windows . GetFileInformationByHandleEx ( windows .Handle (f .Fd ()), windows . FileBasicInfo , (* byte )(unsafe .Pointer (bi )), uint32 (unsafe .Sizeof (* bi ))); err != nil {
3124 return nil , & os.PathError {Op : "GetFileInformationByHandleEx" , Path : f .Name (), Err : err }
3225 }
3326 runtime .KeepAlive (f )
@@ -36,7 +29,7 @@ func GetFileBasicInfo(f *os.File) (*FileBasicInfo, error) {
3629
3730// SetFileBasicInfo sets times and attributes for a file.
3831func SetFileBasicInfo (f * os.File , bi * FileBasicInfo ) error {
39- if err := setFileInformationByHandle ( syscall .Handle (f .Fd ()), fileBasicInfo , (* byte )(unsafe .Pointer (bi )), uint32 (unsafe .Sizeof (* bi ))); err != nil {
32+ if err := windows . SetFileInformationByHandle ( windows .Handle (f .Fd ()), windows . FileBasicInfo , (* byte )(unsafe .Pointer (bi )), uint32 (unsafe .Sizeof (* bi ))); err != nil {
4033 return & os.PathError {Op : "SetFileInformationByHandle" , Path : f .Name (), Err : err }
4134 }
4235 runtime .KeepAlive (f )
@@ -53,7 +46,7 @@ type FileIDInfo struct {
5346// GetFileID retrieves the unique (volume, file ID) pair for a file.
5447func GetFileID (f * os.File ) (* FileIDInfo , error ) {
5548 fileID := & FileIDInfo {}
56- if err := getFileInformationByHandleEx ( syscall .Handle (f .Fd ()), fileIDInfo , (* byte )(unsafe .Pointer (fileID )), uint32 (unsafe .Sizeof (* fileID ))); err != nil {
49+ if err := windows . GetFileInformationByHandleEx ( windows .Handle (f .Fd ()), windows . FileIdInfo , (* byte )(unsafe .Pointer (fileID )), uint32 (unsafe .Sizeof (* fileID ))); err != nil {
5750 return nil , & os.PathError {Op : "GetFileInformationByHandleEx" , Path : f .Name (), Err : err }
5851 }
5952 runtime .KeepAlive (f )
0 commit comments