github.com/cockroachdb/pebble@v1.1.2/vfs/disk_usage_windows.go (about)

     1  // Copyright 2020 The LevelDB-Go and Pebble Authors. All rights reserved. Use
     2  // of this source code is governed by a BSD-style license that can be found in
     3  // the LICENSE file.
     4  
     5  //go:build windows
     6  // +build windows
     7  
     8  package vfs
     9  
    10  import "golang.org/x/sys/windows"
    11  
    12  func (defaultFS) GetDiskUsage(path string) (DiskUsage, error) {
    13  	p, err := windows.UTF16PtrFromString(path)
    14  	if err != nil {
    15  		return DiskUsage{}, err
    16  	}
    17  	var freeBytes uint64
    18  	du := DiskUsage{}
    19  	err = windows.GetDiskFreeSpaceEx(p, &du.AvailBytes, &du.TotalBytes, &freeBytes)
    20  	du.UsedBytes = du.TotalBytes - freeBytes
    21  	return du, err
    22  }