mirror of
https://github.com/DominicBreuker/pspy.git
synced 2025-12-21 11:44:51 +00:00
21 lines
364 B
Go
21 lines
364 B
Go
package fswatcher
|
|
|
|
import (
|
|
"golang.org/x/sys/unix"
|
|
)
|
|
|
|
func Observe(i Inotify, triggerCh chan struct{}, dataCh chan []byte, errCh chan error) {
|
|
buf := make([]byte, 5*unix.SizeofInotifyEvent)
|
|
|
|
for {
|
|
n, err := i.Read(buf)
|
|
if err != nil {
|
|
errCh <- err
|
|
}
|
|
triggerCh <- struct{}{}
|
|
bufCopy := make([]byte, n)
|
|
copy(bufCopy, buf)
|
|
dataCh <- bufCopy
|
|
}
|
|
}
|