[physfs] Getting every instance of overlapping files

Edward Rudd urkle at outoforder.cc
Mon Aug 25 20:11:11 EDT 2014


On Aug 25, 2014, at 8:06 PM, Haydn Harach <hharach at gmail.com> wrote:

> Looking at PHYSFS_openRead() in physfs.c, I've found this little snippet:
> 
> do
>         {
>             char *arcfname = fname;
>             if (verifyPath(i, &arcfname, 0))
>             {
>                 opaque = i->funcs->openRead(i->opaque, arcfname, &fileExists);
>                 if (opaque)
>                     break;
>             } /* if */
>             i = i->next;
>         } while ((i != NULL) && (!fileExists));
> 
> Now, from what I can see, this loop goes through all the paths, and the first one that satisfies the function and returns some data (from the openRead function) and causes 'opaque' to not be NULL, and thus breaks out of the loop.
> 
> So, if I replaced "if (opaque) break;" with "if (opaque) someVector.emplace_back(opaque, i);", then did some cleanup to ensure that I have a vector of FileHandle's instead of one, and return that, this should be exactly what I'm looking for, yes?

More or less, yes that would be exactly what you were looking for.  


More information about the physfs mailing list