Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/20yyq/inotify
Linux inotify
https://github.com/20yyq/inotify
events fsinotify golang inotify inotify-tools inotifywait inotifywatch linux watcher windows
Last synced: about 1 month ago
JSON representation
Linux inotify
- Host: GitHub
- URL: https://github.com/20yyq/inotify
- Owner: 20yyq
- License: bsd-2-clause
- Created: 2023-02-20T00:37:03.000Z (almost 2 years ago)
- Default Branch: master
- Last Pushed: 2023-03-01T11:59:19.000Z (almost 2 years ago)
- Last Synced: 2024-06-21T03:13:51.402Z (6 months ago)
- Topics: events, fsinotify, golang, inotify, inotify-tools, inotifywait, inotifywatch, linux, watcher, windows
- Language: Go
- Homepage:
- Size: 21.5 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# inotify
Linux inotify
## 简介
这是一个可以监听多个文件和目录的项目,可以实现多路监听者。所有监听者保留监听文件或者目录的绝对路径,所有如果监听的文件或者目录本身发生了
DELETE_SELF、MOVE_SELF这两个事件的时候,将会被完全关闭监听者。
# 例子
```gofunc main() {
w, err := inotify.NewWatcher()
if err != nil {
fmt.Println("NewWatcher err", err)
return
}
w.AddWatch("/temp", syscall.IN_OPEN|syscall.IN_CLOSE|syscall.IN_DELETE|syscall.IN_DELETE_SELF|syscall.IN_CREATE|syscall.IN_IGNORED|syscall.IN_MODIFY|syscall.IN_MOVE|syscall.IN_MOVE_SELF|syscall.IN_MOVED_FROM|syscall.IN_MOVED_TO|syscall.IN_MOVE_SELF|syscall.IN_ATTRIB)
fmt.Println("start")
for {
ws, err := w.WaitEvent()
if err != nil {
fmt.Println("WaitEvent Error", err)
time.Sleep(time.Millisecond*300)
continue
}
fmt.Println("WaitEvent:", ws.Mask, ws.FileName, ws.GetEventName())
}
fmt.Println("end")
}```