This repository has been archived on 2015-04-29. You can view files and clone it, but cannot push or open issues or pull requests.
jsh/filesystem.go
2014-10-16 19:02:02 -04:00

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[3])
procPtr = &Filesystem{
args[0], size, used, available, args[4]}
}
return
}