gitlab.com/evatix-go/core@v1.3.55/chmodhelper/IsPartialMatchVariableAttr.go (about) 1 package chmodhelper 2 3 import "gitlab.com/evatix-go/core/constants" 4 5 // IsPartialMatchVariableAttr 6 // 7 // @givenVarAttr can have wildcards "*" 8 // On wildcard present comparison will ignore for that segment. 9 // 10 // Example (will consider this a match): 11 // - givenVarAttr: (rwx : "r*x"), 12 // - rwx : (rwx : "r-x") 13 func IsPartialMatchVariableAttr( 14 givenVarAttr *VarAttribute, 15 rwx string, 16 ) bool { 17 r, w, x := ExpandCharRwx(rwx) 18 19 read := givenVarAttr.isRead.ToByteCondition( 20 ReadChar, 21 NopChar, 22 constants.WildcardChar) 23 write := givenVarAttr.isWrite.ToByteCondition( 24 WriteChar, 25 NopChar, 26 constants.WildcardChar) 27 execute := givenVarAttr.isExecute.ToByteCondition( 28 ExecuteChar, 29 NopChar, 30 constants.WildcardChar, 31 ) 32 33 isRead := givenVarAttr.isRead.IsWildcardOrBool(read == r) 34 isWrite := givenVarAttr.isWrite.IsWildcardOrBool(write == w) 35 isExecute := givenVarAttr.isExecute.IsWildcardOrBool(execute == x) 36 37 return isRead && 38 isWrite && 39 isExecute 40 }