gitlab.com/evatix-go/core@v1.3.55/chmodhelper/ParseRwxToVarAttribute.go (about) 1 package chmodhelper 2 3 import ( 4 "gitlab.com/evatix-go/core/constants" 5 "gitlab.com/evatix-go/core/issetter" 6 ) 7 8 func ParseRwxToVarAttribute(rwx string) (varAttribute *VarAttribute, err error) { 9 length := len(rwx) 10 11 if length != SingleRwxLength { 12 return nil, GetRwxLengthError(rwx) 13 } 14 15 r, w, x := ExpandCharRwx(rwx) 16 17 // any is true 18 isRead := issetter.GetBool(r == ReadChar) 19 isWrite := issetter.GetBool(w == WriteChar) 20 isExecute := issetter.GetBool(x == ExecuteChar) 21 22 // is any has '*' wildcard 23 isReadWildcard := r == constants.WildcardChar 24 isWriteWildcard := w == constants.WildcardChar 25 isExecuteWildcard := x == constants.WildcardChar 26 27 isVarType := isReadWildcard || 28 isWriteWildcard || 29 isExecuteWildcard 30 31 if isVarType { 32 readVal := issetter.GetSet( 33 isReadWildcard, 34 issetter.Wildcard, 35 isRead) 36 37 writeVal := issetter.GetSet( 38 isWriteWildcard, 39 issetter.Wildcard, 40 isWrite) 41 42 execVal := issetter.GetSet( 43 isExecuteWildcard, 44 issetter.Wildcard, 45 isExecute) 46 47 return &VarAttribute{ 48 rawInput: rwx, 49 isFixedType: !isVarType, 50 isRead: readVal, 51 isWrite: writeVal, 52 isExecute: execVal, 53 }, nil 54 } 55 56 return &VarAttribute{ 57 rawInput: rwx, 58 isFixedType: !isVarType, 59 isRead: isRead, 60 isWrite: isWrite, 61 isExecute: isExecute, 62 }, nil 63 }