From 824fa8f17a092cd7f5d665bef3c907032b213959 Mon Sep 17 00:00:00 2001 From: Audrius Butkevicius Date: Wed, 24 Jun 2015 22:05:27 +0100 Subject: [PATCH] Fix go lint warnings --- internal/osutil/glob_windows.go | 1 + internal/symlinks/symlink_windows.go | 20 ++++++++++---------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/internal/osutil/glob_windows.go b/internal/osutil/glob_windows.go index ef35bba67..afb017c7d 100644 --- a/internal/osutil/glob_windows.go +++ b/internal/osutil/glob_windows.go @@ -15,6 +15,7 @@ import ( "strings" ) +// Glob implements filepath.Glob, but works with Windows long path prefixes. // Deals with https://github.com/golang/go/issues/10577 func Glob(pattern string) (matches []string, err error) { if !hasMeta(pattern) { diff --git a/internal/symlinks/symlink_windows.go b/internal/symlinks/symlink_windows.go index 5a14d3efd..6d0ba715c 100644 --- a/internal/symlinks/symlink_windows.go +++ b/internal/symlinks/symlink_windows.go @@ -21,11 +21,11 @@ import ( ) const ( - FSCTL_GET_REPARSE_POINT = 0x900a8 - FILE_FLAG_OPEN_REPARSE_POINT = 0x00200000 - FILE_ATTRIBUTE_REPARSE_POINT = 0x400 - IO_REPARSE_TAG_SYMLINK = 0xA000000C - SYMBOLIC_LINK_FLAG_DIRECTORY = 0x1 + Win32FsctlGetReparsePoint = 0x900a8 + Win32FileFlagOpenReparsePoint = 0x00200000 + Win32FileAttributeReparsePoint = 0x400 + Win32IOReparseTagSymlink = 0xA000000C + Win32SymbolicLinkFlagDirectory = 0x1 ) var ( @@ -106,7 +106,7 @@ func Read(path string) (string, uint32, error) { if err != nil { return "", protocol.FlagSymlinkMissingTarget, err } - handle, err := syscall.CreateFile(ptr, 0, syscall.FILE_SHARE_READ|syscall.FILE_SHARE_WRITE|syscall.FILE_SHARE_DELETE, nil, syscall.OPEN_EXISTING, syscall.FILE_FLAG_BACKUP_SEMANTICS|FILE_FLAG_OPEN_REPARSE_POINT, 0) + handle, err := syscall.CreateFile(ptr, 0, syscall.FILE_SHARE_READ|syscall.FILE_SHARE_WRITE|syscall.FILE_SHARE_DELETE, nil, syscall.OPEN_EXISTING, syscall.FILE_FLAG_BACKUP_SEMANTICS|Win32FileFlagOpenReparsePoint, 0) if err != nil || handle == syscall.InvalidHandle { return "", protocol.FlagSymlinkMissingTarget, err } @@ -114,12 +114,12 @@ func Read(path string) (string, uint32, error) { var ret uint16 var data reparseData - r1, _, err := syscall.Syscall9(procDeviceIoControl.Addr(), 8, uintptr(handle), FSCTL_GET_REPARSE_POINT, 0, 0, uintptr(unsafe.Pointer(&data)), unsafe.Sizeof(data), uintptr(unsafe.Pointer(&ret)), 0, 0) + r1, _, err := syscall.Syscall9(procDeviceIoControl.Addr(), 8, uintptr(handle), Win32FsctlGetReparsePoint, 0, 0, uintptr(unsafe.Pointer(&data)), unsafe.Sizeof(data), uintptr(unsafe.Pointer(&ret)), 0, 0) if r1 == 0 { return "", protocol.FlagSymlinkMissingTarget, err } - var flags uint32 = 0 + var flags uint32 attr, err := syscall.GetFileAttributes(ptr) if err != nil { flags = protocol.FlagSymlinkMissingTarget @@ -154,10 +154,10 @@ func Create(source, target string, flags uint32) error { stat, err := os.Stat(path) if err == nil && stat.IsDir() { - mode = SYMBOLIC_LINK_FLAG_DIRECTORY + mode = Win32SymbolicLinkFlagDirectory } } else if flags&protocol.FlagDirectory != 0 { - mode = SYMBOLIC_LINK_FLAG_DIRECTORY + mode = Win32SymbolicLinkFlagDirectory } r0, _, err := syscall.Syscall(procCreateSymbolicLink.Addr(), 3, uintptr(unsafe.Pointer(srcp)), uintptr(unsafe.Pointer(trgp)), uintptr(mode))