mirror of
https://github.com/stashapp/stash.git
synced 2025-12-18 04:44:37 +03:00
Add cdp support for xpath scrapers (#625)
Co-authored-by: WithoutPants <53250216+WithoutPants@users.noreply.github.com>
This commit is contained in:
36
vendor/github.com/knq/sysutil/sysutil_linux.go
generated
vendored
Normal file
36
vendor/github.com/knq/sysutil/sysutil_linux.go
generated
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
// +build linux
|
||||
|
||||
package sysutil
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"io/ioutil"
|
||||
"strconv"
|
||||
"time"
|
||||
)
|
||||
|
||||
var (
|
||||
btimePrefix = []byte("btime ")
|
||||
lineEnd = []byte("\n")
|
||||
)
|
||||
|
||||
func init() {
|
||||
buf, err := ioutil.ReadFile("/proc/stat")
|
||||
if err != nil {
|
||||
btime = time.Now()
|
||||
return
|
||||
}
|
||||
|
||||
for _, line := range bytes.SplitN(buf, lineEnd, -1) {
|
||||
if bytes.HasPrefix(line, btimePrefix) {
|
||||
t, err := strconv.ParseInt(string(line[len(btimePrefix):]), 10, 64)
|
||||
if err != nil {
|
||||
btime = time.Now()
|
||||
return
|
||||
}
|
||||
|
||||
btime = time.Unix(t, 0)
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user