graphql-engine/cli/update/hide_windows.go
Mohd Bilal 52f21e7261 cli: refactor update package to use internal/errors
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/6524
Co-authored-by: Aravind K P <8335904+scriptonist@users.noreply.github.com>
GitOrigin-RevId: 919262c2618a1319441ce3730802c06bd5bd450a
2022-11-02 07:20:53 +00:00

26 lines
564 B
Go

package update
// shamelessly copied from
// https://github.com/inconshreveable/go-update/blob/master/hide_windows.go
import (
"syscall"
"unsafe"
"github.com/hasura/graphql-engine/cli/v2/internal/errors"
)
func hideFile(path string) error {
var op errors.Op = "update.hideFile"
kernel32 := syscall.NewLazyDLL("kernel32.dll")
setFileAttributes := kernel32.NewProc("SetFileAttributesW")
r1, _, err := setFileAttributes.Call(uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr(path))), 2)
if r1 == 0 {
return errors.E(op, err)
} else {
return nil
}
}