[physfs] descent and physfs
Ryan C. Gordon
icculus at clutteredmind.org
Tue Mar 18 03:39:01 EST 2003
> 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.
> 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.
This works since win32 is "case-retensive"...it'll store the filename's
case, but it's not picky when reopening it with a different case.
Obviously, this adds overhead (but only at file open time, and you
shouldn't be doing file i/o of any sort in time-critical code anyhow), and
on win32, really only serves to keep developers honest in regards to
cross-platform issues) and confuse end users.
Someone on IRC just informed me that some versions of win32 do strange
things with various SMB/Samba implementations (such as uppercase all
filenames, etc), so this might be nasty.
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. :)
We'll definitely make the Descent-related archivers case-insensitive, at
> By that, you mean that the when the client needs a file, it (the
> client) would enumerate and then compare case-insensitively against
> each item in the list, until it finds what it's looking for, right?
Correct. In fact, I might write this up as a public domain example in the
"extras" directory, so it can be cut-and-pasted into programs that need
it. In fact, that might be the best path. I dunno. Comments are welcome.
More information about the physfs