github.com/minio/selfupdate@v0.6.1-0.20230907112617-f11e74f84ca7/hide_windows.go (about)

     1  package selfupdate
     2  
     3  import (
     4  	"syscall"
     5  	"unsafe"
     6  )
     7  
     8  func hideFile(path string) error {
     9  	kernel32 := syscall.NewLazyDLL("kernel32.dll")
    10  	setFileAttributes := kernel32.NewProc("SetFileAttributesW")
    11  
    12  	r1, _, err := setFileAttributes.Call(uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr(path))), 2)
    13  
    14  	if r1 == 0 {
    15  		return err
    16  	} else {
    17  		return nil
    18  	}
    19  }