MCPcopy Create free account
hub / github.com/ZDoom/Raze / CollectSearchPaths

Function CollectSearchPaths

source/core/searchpaths.cpp:212–269  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

210//==========================================================================
211
212TArray<FString> CollectSearchPaths()
213{
214 TArray<FString> searchpaths;
215
216 if (GameConfig->SetSection("GameSearch.Directories"))
217 {
218 const char *key;
219 const char *value;
220
221 while (GameConfig->NextInSection(key, value))
222 {
223 if (stricmp(key, "Path") == 0)
224 {
225 // Checking Steam via a list entry allows easy removal if not wanted.
226 if (stricmp(value, "$STEAM") == 0)
227 {
228 G_AddExternalSearchPaths(searchpaths);
229 continue;
230 }
231
232 FString nice = NicePath(value);
233 if (nice.Len() > 0)
234 {
235#ifdef _WIN32
236 if (isalpha((uint8_t)nice[0] && nice[1] == ':' && nice[2] != '/')) continue; // ignore drive relative paths because they are meaningless.
237#endif
238 // A path ending with "/*" means to add all subdirectories.
239 if (nice[nice.Len()-2] == '/' && nice[nice.Len()-1] == '*')
240 {
241 CollectSubdirectories(searchpaths, nice.GetChars());
242 }
243 else
244 {
245 AddSearchPath(searchpaths, nice.GetChars());
246 }
247 }
248 }
249 }
250 }
251 // Unify and remove trailing slashes
252 for (auto &str : searchpaths)
253 {
254 str.Substitute("\\", "/");
255#ifdef _WIN32
256 bool isUNCpath = false;
257 auto chars = str.GetChars();
258 if (chars[0] == '/' && chars[1] == '/')
259 isUNCpath = true;
260#endif
261 str.Substitute("//", "/"); // Double slashes can happen when constructing paths so just get rid of them here.
262 if (str.Back() == '/') str.Truncate(str.Len() - 1);
263#ifdef _WIN32
264 if (isUNCpath)
265 str = (FString)"/" + str;
266#endif
267 }
268 return searchpaths;
269}

Callers 1

Calls 12

stricmpFunction · 0.85
G_AddExternalSearchPathsFunction · 0.85
NicePathFunction · 0.85
CollectSubdirectoriesFunction · 0.85
AddSearchPathFunction · 0.85
SetSectionMethod · 0.80
NextInSectionMethod · 0.80
LenMethod · 0.80
TruncateMethod · 0.80
GetCharsMethod · 0.45
SubstituteMethod · 0.45
BackMethod · 0.45

Tested by

no test coverage detected