1 // Copyright 2012 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
7 // Package fsnotify provides a platform-independent interface for file system notifications.
16 // Event represents a single file system notification.
18 Name string // Relative path to the file or directory.
19 Op Op // File operation that triggered the event.
22 // Op describes a set of file operations.
25 // These are the generalized file operations that can trigger a notification.
34 func (op Op) String() string {
35 // Use a buffer for efficient string concatenation
36 var buffer bytes.Buffer
38 if op&Create == Create {
39 buffer.WriteString("|CREATE")
41 if op&Remove == Remove {
42 buffer.WriteString("|REMOVE")
44 if op&Write == Write {
45 buffer.WriteString("|WRITE")
47 if op&Rename == Rename {
48 buffer.WriteString("|RENAME")
50 if op&Chmod == Chmod {
51 buffer.WriteString("|CHMOD")
53 if buffer.Len() == 0 {
56 return buffer.String()[1:] // Strip leading pipe
59 // String returns a string representation of the event in the form
60 // "file: REMOVE|WRITE|..."
61 func (e Event) String() string {
62 return fmt.Sprintf("%q: %s", e.Name, e.Op.String())
65 // Common errors that can be reported by a watcher
66 var ErrEventOverflow = errors.New("fsnotify queue overflow")