api_windows_x64.go 593 B

1234567891011121314151617181920
  1. //go:build windows && (amd64 || arm64 || ppc64 || ppc64le || s390x || mips64 || mips64le)
  2. package yu_file
  3. import (
  4. yu_sys "gogs.qqck.cn/s/tools/sys"
  5. "time"
  6. )
  7. func Openfile(name string, dwDesiredAccess, dwShareMode, dwCreationDisposition, dwFlagsAndAttributes uintptr) uintptr {
  8. _open:
  9. j_fd, _, j_errno := yu_sys.CreateFileW.Call(yu_sys.S{yu_sys.Unicode, name}, dwDesiredAccess, dwShareMode, 0, dwCreationDisposition, dwFlagsAndAttributes, 0)
  10. if j_errno == error_SHARING_VIOLATION {
  11. time.Sleep(time.Microsecond)
  12. goto _open
  13. } else if int64(j_fd) == -1 {
  14. return 0
  15. }
  16. return j_fd
  17. }