Debian Codegraph @

watcher/fileEvent.go

raw symbols SCIP
1 package watcher
2
3 import "fmt"
4
5 //"log"
6
7 const (
8 // NONE means no event, initial state.
9 NONE = iota
10 // CREATED means file was created.
11 CREATED
12 // DELETED means file was deleted.
13 DELETED
14 // MODIFIED means file was modified.
15 MODIFIED
16 // PERM means changed permissions
17 PERM
18 // NOEXIST means file does not exist.
19 NOEXIST
20 // NOPERM means no permissions for the file (see const block comment).
21 NOPERM
22 // INVALID means any type of error not represented above.
23 INVALID
24 )
25
26 // FileEvent is a wrapper around github.com/howeyc/fsnotify.FileEvent
27 type FileEvent struct {
28 Event int
29 Path string
30 UnixNano int64
31 }
32
33 // newFileEvent creates a new file event.
34 func newFileEvent(op int, path string, unixNano int64) *FileEvent {
35 //log.Printf("to channel %+v\n", originEvent)
36 return &FileEvent{Event: op, Path: path, UnixNano: unixNano}
37 }
38
39 // String returns an eye friendly version of this event.
40 func (fe *FileEvent) String() string {
41 var status string
42 switch fe.Event {
43 case CREATED:
44 status = "was created"
45 case DELETED:
46 status = "was deleted"
47 case MODIFIED:
48 status = "was modified"
49 case PERM:
50 status = "permissions changed"
51 case NOEXIST:
52 status = "does not exist"
53 case NOPERM:
54 status = "is not accessible (permission)"
55 case INVALID:
56 status = "is invalid"
57 }
58 return fmt.Sprintf("%s %s", fe.Path, status)
59 }