github.com/misseven0/notify@v0.0.0-20230519123055-c1422e46da05/watchpoint_readdcw.go (about) 1 // Copyright (c) 2014-2015 The Notify Authors. All rights reserved. 2 // Use of this source code is governed by the MIT license that can be 3 // found in the LICENSE file. 4 5 //go:build windows 6 // +build windows 7 8 package notify 9 10 // eventmask uses ei to create a new event which contains internal flags used by 11 // notify package logic. If one of FileAction* masks is detected, this function 12 // adds corresponding FileNotifyChange* values. This allows non registered 13 // FileAction* events to be passed on. 14 func eventmask(ei EventInfo, extra Event) (e Event) { 15 if e = ei.Event() | extra; e&fileActionAll != 0 { 16 if ev, ok := ei.(*event); ok { 17 switch ev.ftype { 18 case fTypeFile: 19 e |= FileNotifyChangeFileName 20 case fTypeDirectory: 21 e |= FileNotifyChangeDirName 22 case fTypeUnknown: 23 e |= fileNotifyChangeModified 24 } 25 return e &^ fileActionAll 26 } 27 } 28 return 29 } 30 31 // matches reports a match only when: 32 // 33 // - for user events, when event is present in the given set 34 // - for internal events, when additionally both event and set have omit bit set 35 // 36 // Internal events must not be sent to user channels and vice versa. 37 func matches(set, event Event) bool { 38 return (set&omit)^(event&omit) == 0 && (set&event == event || set&fileNotifyChangeModified&event != 0) 39 }