MCPcopy Create free account
hub / github.com/BZFlag-Dev/bzflag / match_mask

Function match_mask

plugins/plugin_utils/plugin_files.cpp:164–205  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

162}
163
164static int match_mask(const char* mask, const char* string) {
165 if (mask == NULL) {
166 return 0;
167 }
168
169 if (string == NULL) {
170 return 0;
171 }
172
173 if ((mask[0] == '*') && (mask[1] == '\0')) {
174 return 1; /* instant match */
175 }
176
177 while (*mask != '\0') {
178 if (*mask == '*') {
179 mask++;
180 switch (match_multi(&mask, &string)) {
181 case +1:
182 return 1;
183 case -1:
184 return 0;
185 }
186 }
187 else if (*string == '\0') {
188 return 0;
189 }
190 else if ((*mask == '?') || (*mask == *string)) {
191 mask++;
192 string++;
193 }
194 else {
195 return 0;
196 }
197 }
198
199 if (*string == '\0') {
200 return 1;
201 }
202 else {
203 return 0;
204 }
205}
206
207bool LinuxAddFileStack(const char* szPathName, const char* fileMask,
208 bool bRecursive, std::vector<std::string> &list,

Callers 1

LinuxAddFileStackFunction · 0.70

Calls 1

match_multiFunction · 0.70

Tested by

no test coverage detected