Merge pull request #70 from vrecan/win_disk

DiskPartitions Fails if cd not in drive And used and usedPercent are missing in windows
pull/73/head
shirou 10 years ago
commit 20ad984599

@ -41,11 +41,11 @@ func DiskUsage(path string) (*DiskUsageStat, error) {
return nil, err
}
ret = &DiskUsageStat{
Path: path,
Total: uint64(lpTotalNumberOfBytes),
Free: uint64(lpTotalNumberOfFreeBytes),
// Used: uint64(lpTotalNumberOfBytes) - uint64(lpTotalNumberOfFreeBytes)
// UsedPercent: (float64(lpTotalNumberOfBytes) - float64(lpTotalNumberOfFreeBytes)) / float64(lpTotalNumberOfBytes) * 100
Path: path,
Total: uint64(lpTotalNumberOfBytes),
Free: uint64(lpTotalNumberOfFreeBytes),
Used: uint64(lpTotalNumberOfBytes) - uint64(lpTotalNumberOfFreeBytes),
UsedPercent: (float64(lpTotalNumberOfBytes) - float64(lpTotalNumberOfFreeBytes)) / float64(lpTotalNumberOfBytes) * 100,
// InodesTotal: 0,
// InodesFree: 0,
// InodesUsed: 0,
@ -93,6 +93,9 @@ func DiskPartitions(all bool) ([]DiskPartitionStat, error) {
uintptr(unsafe.Pointer(&lpFileSystemNameBuffer[0])),
uintptr(len(lpFileSystemNameBuffer)))
if driveret == 0 {
if typeret == 5 {
continue //device is not ready will happen if there is no disk in the drive
}
return ret, err
}
opts := "rw"

Loading…
Cancel
Save