backend_other.go 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. //go:build !darwin && !dragonfly && !freebsd && !openbsd && !linux && !netbsd && !solaris && !windows
  2. // +build !darwin,!dragonfly,!freebsd,!openbsd,!linux,!netbsd,!solaris,!windows
  3. package fsnotify
  4. import (
  5. "fmt"
  6. "runtime"
  7. )
  8. // Watcher watches a set of files, delivering events to a channel.
  9. type Watcher struct{}
  10. // NewWatcher creates a new Watcher.
  11. func NewWatcher() (*Watcher, error) {
  12. return nil, fmt.Errorf("fsnotify not supported on %s", runtime.GOOS)
  13. }
  14. // Close removes all watches and closes the events channel.
  15. func (w *Watcher) Close() error {
  16. return nil
  17. }
  18. // Add starts monitoring the path for changes.
  19. //
  20. // A path can only be watched once; attempting to watch it more than once will
  21. // return an error. Paths that do not yet exist on the filesystem cannot be
  22. // added. A watch will be automatically removed if the path is deleted.
  23. //
  24. // A path will remain watched if it gets renamed to somewhere else on the same
  25. // filesystem, but the monitor will get removed if the path gets deleted and
  26. // re-created, or if it's moved to a different filesystem.
  27. //
  28. // Notifications on network filesystems (NFS, SMB, FUSE, etc.) or special
  29. // filesystems (/proc, /sys, etc.) generally don't work.
  30. //
  31. // # Watching directories
  32. //
  33. // All files in a directory are monitored, including new files that are created
  34. // after the watcher is started. Subdirectories are not watched (i.e. it's
  35. // non-recursive).
  36. //
  37. // # Watching files
  38. //
  39. // Watching individual files (rather than directories) is generally not
  40. // recommended as many tools update files atomically. Instead of "just" writing
  41. // to the file a temporary file will be written to first, and if successful the
  42. // temporary file is moved to to destination removing the original, or some
  43. // variant thereof. The watcher on the original file is now lost, as it no
  44. // longer exists.
  45. //
  46. // Instead, watch the parent directory and use Event.Name to filter out files
  47. // you're not interested in. There is an example of this in [cmd/fsnotify/file.go].
  48. func (w *Watcher) Add(name string) error {
  49. return nil
  50. }
  51. // Remove stops monitoring the path for changes.
  52. //
  53. // Directories are always removed non-recursively. For example, if you added
  54. // /tmp/dir and /tmp/dir/subdir then you will need to remove both.
  55. //
  56. // Removing a path that has not yet been added returns [ErrNonExistentWatch].
  57. func (w *Watcher) Remove(name string) error {
  58. return nil
  59. }