-
Notifications
You must be signed in to change notification settings - Fork 1
/
doc_test.go
51 lines (45 loc) · 1.39 KB
/
doc_test.go
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package fanotify_test
import (
"log"
"github.com/opcoder0/fanotify"
)
func ExampleNewListener() {
if _, err := fanotify.NewListener("/", true, fanotify.PostContent); err != nil {
log.Fatal("Cannot create listener for mount /", err)
}
}
func ExampleListener_AddWatch() {
var listener *fanotify.Listener
listener, err := fanotify.NewListener("/", false, fanotify.PermissionNone)
if err != nil {
log.Fatal("Cannot create listener for mount /", err)
}
listener.AddWatch("/home/user", fanotify.FileModified)
}
func ExampleListener_AddWatch_all() {
var listener *fanotify.Listener
var eventTypes fanotify.EventType
listener, err := fanotify.NewListener("/", false, fanotify.PermissionNone)
if err != nil {
log.Fatal("Cannot create listener for path /", err)
}
eventTypes = fanotify.FileAccessed |
fanotify.FileOrDirectoryAccessed |
fanotify.FileModified |
fanotify.FileOpenedForExec |
fanotify.FileAttribChanged |
fanotify.FileOrDirectoryAttribChanged |
fanotify.FileCreated |
fanotify.FileOrDirectoryCreated |
fanotify.FileDeleted |
fanotify.FileOrDirectoryDeleted |
fanotify.WatchedFileDeleted |
fanotify.WatchedFileOrDirectoryDeleted |
fanotify.FileMovedFrom |
fanotify.FileOrDirectoryMovedFrom |
fanotify.FileMovedTo |
fanotify.FileOrDirectoryMovedTo |
fanotify.WatchedFileMoved |
fanotify.WatchedFileOrDirectoryMoved
listener.AddWatch("/home/user", eventTypes)
}