github.com/graybobo/golang.org-package-offline-cache@v0.0.0-20200626051047-6608995c132f/x/exp/fsnotify/fsnotify.go (about)

     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.
     4  
     5  // +build !plan9,!solaris
     6  
     7  // Package fsnotify implements file system notification.
     8  package fsnotify // import "golang.org/x/exp/fsnotify"
     9  
    10  import "fmt"
    11  
    12  // Watch a given file path
    13  func (w *Watcher) Watch(path string) error {
    14  	return w.watch(path)
    15  }
    16  
    17  // Remove a watch on a file
    18  func (w *Watcher) RemoveWatch(path string) error {
    19  	return w.removeWatch(path)
    20  }
    21  
    22  // String formats the event e in the form
    23  // "filename: DELETE|MODIFY|..."
    24  func (e *FileEvent) String() string {
    25  	var events string = ""
    26  
    27  	if e.IsCreate() {
    28  		events += "|" + "CREATE"
    29  	}
    30  
    31  	if e.IsDelete() {
    32  		events += "|" + "DELETE"
    33  	}
    34  
    35  	if e.IsModify() {
    36  		events += "|" + "MODIFY"
    37  	}
    38  
    39  	if e.IsRename() {
    40  		events += "|" + "RENAME"
    41  	}
    42  
    43  	if e.IsAttrib() {
    44  		events += "|" + "ATTRIB"
    45  	}
    46  
    47  	if len(events) > 0 {
    48  		events = events[1:]
    49  	}
    50  
    51  	return fmt.Sprintf("%q: %s", e.Name, events)
    52  }