//go:build windows && (amd64 || arm64 || ppc64 || ppc64le || s390x || mips64 || mips64le)

package yu_file

import (
	yu_sys "gogs.qqck.cn/s/tools/sys"
	"time"
)

func Openfile(name string, dwDesiredAccess, dwShareMode, dwCreationDisposition, dwFlagsAndAttributes uintptr) uintptr {
_open:
	j_fd, _, j_errno := yu_sys.CreateFileW.Call(yu_sys.S{yu_sys.Unicode, name}, dwDesiredAccess, dwShareMode, 0, dwCreationDisposition, dwFlagsAndAttributes, 0)
	if j_errno == error_SHARING_VIOLATION {
		time.Sleep(time.Microsecond)
		goto _open
	} else if int64(j_fd) == -1 {
		return 0
	}
	return j_fd
}
