|
|
|
@ -19,8 +19,10 @@ import (
|
|
|
|
|
"github.com/shirou/gopsutil/v4/internal/common"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
const volumeNameBufferLength = uint32(windows.MAX_PATH + 1)
|
|
|
|
|
const volumePathBufferLength = volumeNameBufferLength
|
|
|
|
|
const (
|
|
|
|
|
volumeNameBufferLength = uint32(windows.MAX_PATH + 1)
|
|
|
|
|
volumePathBufferLength = volumeNameBufferLength
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
var (
|
|
|
|
|
procGetDiskFreeSpaceExW = common.Modkernel32.NewProc("GetDiskFreeSpaceExW")
|
|
|
|
@ -165,7 +167,8 @@ func PartitionsWithContext(ctx context.Context, _ bool) ([]PartitionStat, error)
|
|
|
|
|
nextVolHandle,
|
|
|
|
|
uintptr(unsafe.Pointer(&volNameBuf[0])),
|
|
|
|
|
uintptr(volumeNameBufferLength)); err != nil && volRet == 0 {
|
|
|
|
|
if errno, ok := err.(syscall.Errno); ok && errno == windows.ERROR_NO_MORE_FILES {
|
|
|
|
|
var errno syscall.Errno
|
|
|
|
|
if errors.As(err, &errno) && errno == windows.ERROR_NO_MORE_FILES {
|
|
|
|
|
break
|
|
|
|
|
}
|
|
|
|
|
warnings.Add(fmt.Errorf("failed to find next volume: %w", err))
|
|
|
|
@ -257,7 +260,9 @@ func IOCountersWithContext(_ context.Context, names ...string) (map[string]IOCou
|
|
|
|
|
return drivemap, err
|
|
|
|
|
}
|
|
|
|
|
for _, v := range lpBuffer[:lpBufferLen] {
|
|
|
|
|
if 'A' <= v && v <= 'Z' {
|
|
|
|
|
if v < 'A' || v > 'Z' {
|
|
|
|
|
continue
|
|
|
|
|
}
|
|
|
|
|
path := string(rune(v)) + ":"
|
|
|
|
|
typepath, _ := windows.UTF16PtrFromString(path)
|
|
|
|
|
typeret := windows.GetDriveType(typepath)
|
|
|
|
@ -293,7 +298,6 @@ func IOCountersWithContext(_ context.Context, names ...string) (map[string]IOCou
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return drivemap, nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|