- for (I = 0; I < MAX_SEARCH_PATHS; ++I) {
- unsigned Mask = (0x01U << I);
- if (Where & Mask) {
- char* Path = Find (SearchPaths[I], Name);
- if (Path) {
- /* Found the file */
- return Path;
- }
- }
+ for (I = 0; I < CollCount (P); ++I) {
+
+ /* Copy the next path element into the buffer */
+ SB_CopyStr (&PathName, CollConstAt (P, I));
+
+ /* Add a path separator and the filename */
+ if (SB_NotEmpty (&PathName)) {
+ SB_AppendChar (&PathName, '/');
+ }
+ SB_AppendStr (&PathName, File);
+ SB_Terminate (&PathName);
+
+ /* Check if this file exists */
+ if (access (SB_GetBuf (&PathName), 0) == 0) {
+ /* The file exists, we're done */
+ Name = xstrdup (SB_GetBuf (&PathName));
+ break;
+ }