File: subsystem.go

package info (click to toggle)
golang-github-ungerik-go-sysfs 0.0~git20210209.68e6f4d-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 92 kB
  • sloc: makefile: 2
file content (28 lines) | stat: -rw-r--r-- 513 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
package sysfs

import (
// "os"
)

type Subsystem string

func (subsys Subsystem) Exists() bool {
	return dirExists(string(subsys))
}

func (subsys Subsystem) Name() string {
	return string(subsys)[5:]
}

func (subsys Subsystem) Objects() []Object {
	path := string(subsys) + "/"
	objects := make([]Object, 0)
	lsDirs(path, func(name string) {
		objects = append(objects, Object(path+name))
	})
	return objects
}

func (subsys Subsystem) Object(name string) Object {
	return Object(string(subsys) + "/" + name)
}