github.com/hernad/nomad@v1.6.112/command/agent/host/windows.go (about)

     1  // Copyright (c) HashiCorp, Inc.
     2  // SPDX-License-Identifier: MPL-2.0
     3  
     4  //go:build windows
     5  // +build windows
     6  
     7  package host
     8  
     9  import (
    10  	"os"
    11  	"syscall"
    12  	"unsafe"
    13  )
    14  
    15  func uname() string {
    16  	return ""
    17  }
    18  
    19  func resolvConf() string {
    20  	return ""
    21  }
    22  
    23  func etcHosts() string {
    24  	return ""
    25  }
    26  
    27  func mountedPaths() (disks []string) {
    28  	for _, c := range "ABCDEFGHIJKLMNOPQRSTUVWXYZ" {
    29  		d := string(c) + ":\\"
    30  		_, err := os.Stat(d)
    31  		if err == nil {
    32  			disks = append(disks, d)
    33  		}
    34  	}
    35  	return disks
    36  }
    37  
    38  type df struct {
    39  	size  int64
    40  	avail int64
    41  }
    42  
    43  func makeDf(path string) (*df, error) {
    44  	h, err := syscall.LoadDLL("kernel32.dll")
    45  	if err != nil {
    46  		return nil, err
    47  	}
    48  
    49  	c, err := h.FindProc("GetDiskFreeSpaceExW")
    50  	if err != nil {
    51  		return nil, err
    52  	}
    53  
    54  	df := &df{}
    55  
    56  	c.Call(uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr(path))),
    57  		uintptr(unsafe.Pointer(&df.size)),
    58  		uintptr(unsafe.Pointer(&df.avail)))
    59  
    60  	return df, nil
    61  }
    62  
    63  func (d *df) total() uint64 {
    64  	return uint64(d.size)
    65  }
    66  
    67  func (d *df) available() uint64 {
    68  	return uint64(d.avail)
    69  }