Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Partitions and UsableBytes (Windows Only) #159

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions block.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,14 @@ type Disk struct {

// Partition describes a logical division of a Disk.
type Partition struct {
Disk *Disk `json:"-"`
Name string `json:"name"`
Label string `json:"label"`
MountPoint string `json:"mount_point"`
SizeBytes uint64 `json:"size_bytes"`
Type string `json:"type"`
IsReadOnly bool `json:"read_only"`
Disk *Disk `json:"-"`
Name string `json:"name"`
Label string `json:"label"`
MountPoint string `json:"mount_point"`
SizeBytes uint64 `json:"size_bytes"`
UsableBytes uint64 `json:"usable_bytes"`
Type string `json:"type"`
IsReadOnly bool `json:"read_only"`
}

// BlockInfo describes all disk drives and partitions in the host system.
Expand Down
13 changes: 7 additions & 6 deletions block_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,13 @@ func (ctx *context) blockFillInfo(info *BlockInfo) error {
if logicaldisktodiskpartition.Antecedent == desiredAntecedent && logicaldisktodiskpartition.Dependent == desiredDependent {
// Appending Partition
p := &Partition{
Name: logicaldisk.Caption,
Label: logicaldisk.Caption,
SizeBytes: logicaldisk.Size,
MountPoint: logicaldisk.DeviceID,
Type: diskpartition.Type,
IsReadOnly: toReadOnly(diskpartition.Access), // TODO: add information
Name: logicaldisk.Caption,
Label: logicaldisk.Caption,
SizeBytes: logicaldisk.Size,
UsableBytes: logicaldisk.FreeSpace,
MountPoint: logicaldisk.DeviceID,
Type: diskpartition.Type,
IsReadOnly: toReadOnly(diskpartition.Access), // TODO: add information
}
disk.Partitions = append(disk.Partitions, p)
break
Expand Down