main
1//go:build windows
2
3// Code generated by 'go generate' using "github.com/Microsoft/go-winio/tools/mkwinsyscall"; DO NOT EDIT.
4
5package fs
6
7import (
8 "syscall"
9 "unsafe"
10
11 "golang.org/x/sys/windows"
12)
13
14var _ unsafe.Pointer
15
16// Do the interface allocations only once for common
17// Errno values.
18const (
19 errnoERROR_IO_PENDING = 997
20)
21
22var (
23 errERROR_IO_PENDING error = syscall.Errno(errnoERROR_IO_PENDING)
24 errERROR_EINVAL error = syscall.EINVAL
25)
26
27// errnoErr returns common boxed Errno values, to prevent
28// allocations at runtime.
29func errnoErr(e syscall.Errno) error {
30 switch e {
31 case 0:
32 return errERROR_EINVAL
33 case errnoERROR_IO_PENDING:
34 return errERROR_IO_PENDING
35 }
36 return e
37}
38
39var (
40 modkernel32 = windows.NewLazySystemDLL("kernel32.dll")
41
42 procCreateFileW = modkernel32.NewProc("CreateFileW")
43)
44
45func CreateFile(name string, access AccessMask, mode FileShareMode, sa *windows.SecurityAttributes, createmode FileCreationDisposition, attrs FileFlagOrAttribute, templatefile windows.Handle) (handle windows.Handle, err error) {
46 var _p0 *uint16
47 _p0, err = syscall.UTF16PtrFromString(name)
48 if err != nil {
49 return
50 }
51 return _CreateFile(_p0, access, mode, sa, createmode, attrs, templatefile)
52}
53
54func _CreateFile(name *uint16, access AccessMask, mode FileShareMode, sa *windows.SecurityAttributes, createmode FileCreationDisposition, attrs FileFlagOrAttribute, templatefile windows.Handle) (handle windows.Handle, err error) {
55 r0, _, e1 := syscall.SyscallN(procCreateFileW.Addr(), uintptr(unsafe.Pointer(name)), uintptr(access), uintptr(mode), uintptr(unsafe.Pointer(sa)), uintptr(createmode), uintptr(attrs), uintptr(templatefile))
56 handle = windows.Handle(r0)
57 if handle == windows.InvalidHandle {
58 err = errnoErr(e1)
59 }
60 return
61}