36 lines
772 B
Go
36 lines
772 B
Go
/* File for Filesystem-related structs and methods */
|
|
|
|
package jsh
|
|
|
|
import (
|
|
"errors"
|
|
"strconv"
|
|
)
|
|
|
|
// Filesystem is a struct for marshalling into JSON output for the df utility.
|
|
type Filesystem struct {
|
|
Name string
|
|
Size int
|
|
Used int
|
|
Available int
|
|
MountPoint string
|
|
}
|
|
|
|
// NewFilesystem
|
|
func NewFilesystem(args []string) (procPtr *Filesystem, err error) {
|
|
err = nil
|
|
// 11 = number of fields in the Filesystem struct
|
|
if len(args) != 5 {
|
|
procPtr = &Filesystem{}
|
|
err = errors.New("Unexpected number of columns")
|
|
} else {
|
|
// TODO: add error checking
|
|
size, _ := strconv.Atoi(args[1])
|
|
used, _ := strconv.Atoi(args[2])
|
|
available, _ := strconv.Atoi(args[2])
|
|
procPtr = &Filesystem{
|
|
args[0], size, used, available, args[4]}
|
|
}
|
|
return
|
|
}
|