github.com/reds/docker@v1.11.2-rc1/pkg/system/syscall_windows.go (about) 1 package system 2 3 import ( 4 "fmt" 5 "syscall" 6 "unsafe" 7 ) 8 9 // OSVersion is a wrapper for Windows version information 10 // https://msdn.microsoft.com/en-us/library/windows/desktop/ms724439(v=vs.85).aspx 11 type OSVersion struct { 12 Version uint32 13 MajorVersion uint8 14 MinorVersion uint8 15 Build uint16 16 } 17 18 // GetOSVersion gets the operating system version on Windows. Note that 19 // docker.exe must be manifested to get the correct version information. 20 func GetOSVersion() (OSVersion, error) { 21 var err error 22 osv := OSVersion{} 23 osv.Version, err = syscall.GetVersion() 24 if err != nil { 25 return osv, fmt.Errorf("Failed to call GetVersion()") 26 } 27 osv.MajorVersion = uint8(osv.Version & 0xFF) 28 osv.MinorVersion = uint8(osv.Version >> 8 & 0xFF) 29 osv.Build = uint16(osv.Version >> 16) 30 return osv, nil 31 } 32 33 // Unmount is a platform-specific helper function to call 34 // the unmount syscall. Not supported on Windows 35 func Unmount(dest string) error { 36 return nil 37 } 38 39 // CommandLineToArgv wraps the Windows syscall to turn a commandline into an argument array. 40 func CommandLineToArgv(commandLine string) ([]string, error) { 41 var argc int32 42 43 argsPtr, err := syscall.UTF16PtrFromString(commandLine) 44 if err != nil { 45 return nil, err 46 } 47 48 argv, err := syscall.CommandLineToArgv(argsPtr, &argc) 49 if err != nil { 50 return nil, err 51 } 52 defer syscall.LocalFree(syscall.Handle(uintptr(unsafe.Pointer(argv)))) 53 54 newArgs := make([]string, argc) 55 for i, v := range (*argv)[:argc] { 56 newArgs[i] = string(syscall.UTF16ToString((*v)[:])) 57 } 58 59 return newArgs, nil 60 }