@@ -67,6 +67,42 @@ private class IsWindowsFromSystemProp extends IsWindowsGuard instanceof MethodAc
6767 IsWindowsFromSystemProp ( ) { isOsFromSystemProp ( this , "window%" ) }
6868}
6969
70+ /**
71+ * Holds when the Guard is an equality check between the Field `f` and the string or char constant `compareToLiteral`.
72+ */
73+ private Guard isOsFromFieldEqualityCheck ( Field f , string compareToLiteral ) {
74+ result
75+ .isEquality ( any ( FieldAccess fa | fa .getField ( ) = f ) ,
76+ any ( Literal literal |
77+ ( literal instanceof CharacterLiteral or literal instanceof StringLiteral ) and
78+ literal .getValue ( ) = compareToLiteral
79+ ) , _)
80+ }
81+
82+ private class IsWindowsFromCharPathSeperator extends IsWindowsGuard {
83+ IsWindowsFromCharPathSeperator ( ) {
84+ this = isOsFromFieldEqualityCheck ( any ( FieldFilePathSeparator f ) , ";" )
85+ }
86+ }
87+
88+ private class IsWindowsFromCharSeperator extends IsWindowsGuard {
89+ IsWindowsFromCharSeperator ( ) {
90+ this = isOsFromFieldEqualityCheck ( any ( FieldFileSeparator f ) , "\\" )
91+ }
92+ }
93+
94+ private class IsUnixFromCharPathSeperator extends IsUnixGuard {
95+ IsUnixFromCharPathSeperator ( ) {
96+ this = isOsFromFieldEqualityCheck ( any ( FieldFilePathSeparator f ) , ":" )
97+ }
98+ }
99+
100+ private class IsUnixFromCharSeperator extends IsUnixGuard {
101+ IsUnixFromCharSeperator ( ) {
102+ this = isOsFromFieldEqualityCheck ( any ( FieldFileSeparator f ) , "/" )
103+ }
104+ }
105+
70106private class IsUnixFromSystemProp extends IsAnyUnixGuard instanceof MethodAccess {
71107 IsUnixFromSystemProp ( ) { isOsFromSystemProp ( this , [ "mac%" , "linux%" ] ) }
72108}
0 commit comments