No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

filesystem.go 772B

1234567891011121314151617181920212223242526272829303132333435
  1. /* File for Filesystem-related structs and methods */
  2. package jsh
  3. import (
  4. "errors"
  5. "strconv"
  6. )
  7. // Filesystem is a struct for marshalling into JSON output for the df utility.
  8. type Filesystem struct {
  9. Name string
  10. Size int
  11. Used int
  12. Available int
  13. MountPoint string
  14. }
  15. // NewFilesystem
  16. func NewFilesystem(args []string) (procPtr *Filesystem, err error) {
  17. err = nil
  18. // 11 = number of fields in the Filesystem struct
  19. if len(args) != 5 {
  20. procPtr = &Filesystem{}
  21. err = errors.New("Unexpected number of columns")
  22. } else {
  23. // TODO: add error checking
  24. size, _ := strconv.Atoi(args[1])
  25. used, _ := strconv.Atoi(args[2])
  26. available, _ := strconv.Atoi(args[3])
  27. procPtr = &Filesystem{
  28. args[0], size, used, available, args[4]}
  29. }
  30. return
  31. }