[physfs] descent and physfs

Bradley Bell btb at icculus.org
Tue Mar 18 16:21:13 EST 2003


Quoting "Ryan C. Gordon" <icculus at clutteredmind.org>:

> 
> > That's pretty much what I was envisioning.  If this was to be
> > implemented, what would be the mechanism behind case-insensitivity in
> > the DIR archiver?
> 
> It would fall into the platform/* code. physfs.c's API (caseIsSensitive()
> or whatever) would call something like __PHYSFS_platformSetCaseSensitive()
> and then i/o operations would take that state into account. The DIR
> archiver just calls through to the platform drivers which means it would
> "just work" once this was done.

Okay, so my question then becomes: what would be the mechanism behind
case-insensitivity in the posix platform driver?  

This seems pretty hairy to me, but maybe I'm missing something.
let's start with something simple, like "exists"
this is pseudocode!:
platformExists(char *filename)
{
    if (stat(filename) != -1)
        return 1;

    if (platformIgnoreCase)
    {
        char *d;
        char path[PATH_MAX] = "/";
        LinkedStringList *list, *p;

        for (d = firstdirinfilename(filename); d != NULL; d =
nextdirinfilename(filename))
        {
            if (stat(d) != -1)
            {
                strcat(path, d);
                continue;
            }
            list = enumeratefiles(path);
            p = findinlistinsensitive(list, d);
            if (p)
            {
                strcat(path, p->str);
                strcat(path, "/");
            }
            else
                return 0;
        }
        strcpy(filename, path);
        strcat(filename, "/");
        strcat(filename, basename(filename));
        if (stat(filename) != -1)
            return 1;
        list = enumeratefiles(filename);
        p = findinlistinsensitive(list, d);
        if (p)
            return 1;
    }
    return 0;
}

phew! is there a better way than that?

> 
> > how do you not ignore case on win32?
> 
> Instead of calling the win32 equivalent of fopen() directly, you enumerate
> the files in the given dir and see if there's a case-sensitive match. If
> so, THEN you open that. If there's no match (even if there's one with a
> wrong case), you just opt not to open it. Extra credit for checking each
> element of the path (Does "part1/Part2/PART3" match "PART1/PART2/PART3"?)
> before looking for the actual file.

I see.  I was assuming that nobody would seriously _want_ case sensitivity on
win32.  I don't think PhysicsFS should ever be more picky than the actual FS.

> I'm still torn over whether doing this work is a good idea at all,
> honestly. Might be better to let developers toggle a flag that says
> "always ignore case" but not let them toggle one that always enforces it.
> I dunno. Laziness might win out on this one.  :)

that would work fine for me.

-brad





More information about the physfs mailing list