gf/os/gfsnotify/gfsnotify_event.go

38 lines
1.1 KiB
Go
Raw Normal View History

2021-01-17 21:46:25 +08:00
// Copyright GoFrame Author(https://goframe.org). All Rights Reserved.
2018-04-18 15:17:07 +08:00
//
// ThIs Source Code Form Is subject to the terms of the MIT License.
// If a copy of the MIT was not dIstributed with thIs file,
// You can obtain one at https://github.com/gogf/gf.
2018-04-18 15:17:07 +08:00
package gfsnotify
2019-10-31 23:37:33 +08:00
// String returns current event as string.
func (e *Event) String() string {
2019-06-19 09:06:52 +08:00
return e.event.String()
}
2019-10-31 23:37:33 +08:00
// IsCreate checks whether current event contains file/folder create event.
2018-04-18 15:17:07 +08:00
func (e *Event) IsCreate() bool {
2019-06-19 09:06:52 +08:00
return e.Op == 1 || e.Op&CREATE == CREATE
2018-04-18 15:17:07 +08:00
}
2019-10-31 23:37:33 +08:00
// IsWrite checks whether current event contains file/folder write event.
2018-04-18 15:17:07 +08:00
func (e *Event) IsWrite() bool {
2019-06-19 09:06:52 +08:00
return e.Op&WRITE == WRITE
2018-04-18 15:17:07 +08:00
}
2019-10-31 23:37:33 +08:00
// IsRemove checks whether current event contains file/folder remove event.
2018-04-18 15:17:07 +08:00
func (e *Event) IsRemove() bool {
2019-06-19 09:06:52 +08:00
return e.Op&REMOVE == REMOVE
2018-04-18 15:17:07 +08:00
}
2019-10-31 23:37:33 +08:00
// IsRename checks whether current event contains file/folder rename event.
2018-04-18 15:17:07 +08:00
func (e *Event) IsRename() bool {
2019-06-19 09:06:52 +08:00
return e.Op&RENAME == RENAME
2018-04-18 15:17:07 +08:00
}
2019-10-31 23:37:33 +08:00
// IsChmod checks whether current event contains file/folder chmod event.
2018-04-18 15:17:07 +08:00
func (e *Event) IsChmod() bool {
2019-06-19 09:06:52 +08:00
return e.Op&CHMOD == CHMOD
2018-10-31 19:00:28 +08:00
}