[physfs] Getting every instance of overlapping files

Haydn Harach hharach at gmail.com
Mon Aug 25 20:06:41 EDT 2014


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?


On Mon, Aug 25, 2014 at 3:03 PM, Indy Sams <indy at driftsolutions.com> wrote:

> Hello Haydn,
>
> You should just make your PHYSFS_openReadMulti function, if you copy/paste
> the existing PHYSFS_openRead function it will take you about 5-10 minutes
> to make. You'll just have to use a compiled in copy instead of the system
> copy of PhysFS if your program is Linux compatible.
>
> Best regards,
>  Indy Sams
>  mailto:indy at driftsolutions.com
>
> Monday, August 25, 2014, 4:28:32 PM, you wrote:
>
> HH> PHYSFS_mount wont let me mount the same 'archiveFileName' twice,
> HH> even if the 'mountPoint' is different.
>
>
> HH> On Mon, Aug 25, 2014 at 2:21 PM, Edward Rudd <urkle at outoforder.cc>
> wrote:
> HH>
> HH> On Aug 25, 2014, at 4:04 PM, Haydn Harach <hharach at gmail.com> wrote:
>
> HH> How can I load the archives in separate directories?  Within each
> HH> archive I have a "textures/" folder and a "maps/" folder.  I want
> HH> to keep the "maps/" folders separate so I can load a specific map
> HH> from a specific archive, but I want everything in "textures/" to
> HH> overlap and be overwritten as is the default behavior.
>
>
>
> HH> You would use PHYSFS_mount and specify a subfolder for the second
> argument (mountPoint)..  example
>
>
> HH> PHYSFS_mount( archiveFileName, "/mods/mod1", 0);
>
>
>
>
>
> HH> On Sat, Aug 23, 2014 at 7:37 PM, Haydn Harach <hharach at gmail.com>
> wrote:
> HH>
> HH>
> HH> Ideally, what I want is a `PHYSFS_openReadMulti()` function,
> HH> which returns an array of `PHYSFS_file*` pointers.  I don't mind
> HH> writing this function myself, as long as the underlying system is
> HH> capable of it.  It is open source, after all.
> HH>
>
>
>
> HH> On Sat, Aug 23, 2014 at 5:07 AM, Sik the hedgehog
> HH> <sik.the.hedgehog at gmail.com> wrote:
> HH>
> HH> Then load the archives in separate directories and handle the
> HH>  overriding manually (using a wrapper function for opening files would
> HH>  be helpful here).
> HH>
> HH>  2014-08-23 6:37 GMT-03:00, Haydn Harach <hharach at gmail.com>:
> HH>
> >> Can't - I wont know exactly which files to load until run time (.map
> files
>  >> can refer to other .map files, and that information wont be known
> until the
>  >> player is in the .map).
>
>
>  >> On Sat, Aug 23, 2014 at 3:10 AM, Sik the hedgehog <
>  >> sik.the.hedgehog at gmail.com> wrote:
>
>  >>> Then just take the second option (load .map files when you just mount
>  >>> the archive, leave the .png files for after you've mounted
>  >>> everything).
>
>  >>> 2014-08-23 5:33 GMT-03:00, Haydn Harach <hharach at gmail.com>:
>  >>> > Problem is, I want .png files to be overwritten, but not .map files.
>  >>> When
>  >>> > the mod is loaded initially, it's just a big .zip archive, there
> could
>  >>> > be
>  >>> > .png or .map files within it's sub-directories.
>  >>> >
>  >>> >
>  >>> > On Sat, Aug 23, 2014 at 2:13 AM, Sik the hedgehog <
>  >>> > sik.the.hedgehog at gmail.com> wrote:
>  >>> >
>  >>> >> Two options:
>  >>> >>
>  >>> >> - Mount them in separate directories and just deal with the fact (I
>  >>> >> ended up doing this to prevent mods in my game from overwriting
>  >>> >> configuration and savegame files).
>  >>> >>
>  >>> >> - If the data is going to permanently stay in memory (i.e. you
> won't
>  >>> >> need to read the files after initially mounted), then load the
> files
>  >>> >> the moment you mount them (before mounting the subsequent
> archives).
>  >>> >> The obvious upshot is that if you want you can unmount them after
>  >>> >> loading (since the data is in RAM already).
>  >>> >> _______________________________________________
>  >>> >> physfs mailing list
>  >>> >> physfs at icculus.org
>  >>> >> http://icculus.org/mailman/listinfo/physfs
>  >>> >>
>  >>> >
>  >>> _______________________________________________
>  >>> physfs mailing list
>  >>> physfs at icculus.org
>  >>> http://icculus.org/mailman/listinfo/physfs
>
>
> HH>  _______________________________________________
> HH>  physfs mailing list
> HH>  physfs at icculus.org
> HH>  http://icculus.org/mailman/listinfo/physfs
> HH>
>
> HH>
>
> HH>  _______________________________________________
> HH> physfs mailing list
> HH> physfs at icculus.org
> HH> http://icculus.org/mailman/listinfo/physfs
> HH>
>
>
> HH> _______________________________________________
> HH>  physfs mailing list
> HH>  physfs at icculus.org
> HH>  http://icculus.org/mailman/listinfo/physfs
> HH>
>
> _______________________________________________
> physfs mailing list
> physfs at icculus.org
> http://icculus.org/mailman/listinfo/physfs
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://icculus.org/pipermail/physfs/attachments/20140825/18eb2e80/attachment.html>


More information about the physfs mailing list