...

Source file src/github.com/Microsoft/go-winio/internal/fs/zsyscall_windows.go

Documentation: github.com/Microsoft/go-winio/internal/fs

     1  //go:build windows
     2  
     3  // Code generated by 'go generate' using "github.com/Microsoft/go-winio/tools/mkwinsyscall"; DO NOT EDIT.
     4  
     5  package fs
     6  
     7  import (
     8  	"syscall"
     9  	"unsafe"
    10  
    11  	"golang.org/x/sys/windows"
    12  )
    13  
    14  var _ unsafe.Pointer
    15  
    16  // Do the interface allocations only once for common
    17  // Errno values.
    18  const (
    19  	errnoERROR_IO_PENDING = 997
    20  )
    21  
    22  var (
    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.
    29  func 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  	// TODO: add more here, after collecting data on the common
    37  	// error values see on Windows. (perhaps when running
    38  	// all.bat?)
    39  	return e
    40  }
    41  
    42  var (
    43  	modkernel32 = windows.NewLazySystemDLL("kernel32.dll")
    44  
    45  	procCreateFileW = modkernel32.NewProc("CreateFileW")
    46  )
    47  
    48  func CreateFile(name string, access AccessMask, mode FileShareMode, sa *syscall.SecurityAttributes, createmode FileCreationDisposition, attrs FileFlagOrAttribute, templatefile windows.Handle) (handle windows.Handle, err error) {
    49  	var _p0 *uint16
    50  	_p0, err = syscall.UTF16PtrFromString(name)
    51  	if err != nil {
    52  		return
    53  	}
    54  	return _CreateFile(_p0, access, mode, sa, createmode, attrs, templatefile)
    55  }
    56  
    57  func _CreateFile(name *uint16, access AccessMask, mode FileShareMode, sa *syscall.SecurityAttributes, createmode FileCreationDisposition, attrs FileFlagOrAttribute, templatefile windows.Handle) (handle windows.Handle, err error) {
    58  	r0, _, e1 := syscall.Syscall9(procCreateFileW.Addr(), 7, uintptr(unsafe.Pointer(name)), uintptr(access), uintptr(mode), uintptr(unsafe.Pointer(sa)), uintptr(createmode), uintptr(attrs), uintptr(templatefile), 0, 0)
    59  	handle = windows.Handle(r0)
    60  	if handle == windows.InvalidHandle {
    61  		err = errnoErr(e1)
    62  	}
    63  	return
    64  }
    65  

View as plain text