PhysicsFS
April 3rd, 2007: PhysicsFS release development branch 1.1.1 is ready!
PhysicsFS is a library to provide abstract access to various archives.
It is intended for use in video games, and the design was somewhat
inspired by Quake 3's file subsystem. The programmer defines a "write
directory" on the physical filesystem. No file writing done through the
PhysicsFS API can leave that write directory, for security. For example,
an embedded scripting language cannot write outside of this path if it
uses PhysFS for all of its I/O, which means that untrusted scripts can
run more safely. Symbolic links can be disabled as well, for added
safety. For file reading, the programmer lists directories and archives
that form a "search path". Once the search path is defined, it becomes
a single, transparent hierarchical filesystem. This makes for easy
access to ZIP files in the same way as you access a file directly on
the disk, and it makes it easy to ship a new archive that will override
a previous archive on a per-file basis. Finally, PhysicsFS gives you
platform-abstracted means to determine if CD-ROMs are available, the
user's home directory, where in the real filesystem your program is
running, etc.
To explain better, you have two zipfiles, one has these files:
- music/intro.mid
- graphics/splashscreen.bmp
- mainconfig.cfg
...the other's got these:
- music/hero.mid
- maps/desert.map
...and, finally, in your game's real directory:
- maps/city.map
- graphics/gun.bmp
When you create the search path in PhysicsFS with those three
components, and ask for what's in the "music" directory, you are told:
...in the maps directory:
...in the graphics directory:
...and, finally, in the root (toplevel) directory:
- maps
- music
- graphics
- mainconfig.cfg
The programmer does not know and does not care where each of these
files came from, and what sort of archive (if any) is storing them.
But if he needs to know, he can find out through the PhysicsFS API.
Furthermore, he can take comfort in knowing that those untrusted
scripts we mentioned earlier can't access any other files than these.
The file entries "." and ".." are explicitly forbidden in PhysicsFS.
Places PhysicsFS can be found in use:
- The Build Engine can optionally be
compiled with PhysicsFS support, which is good, because its
standard packfile format offers no compression or long filenames.
- ParaGUI is a cross
platform toolkit built on
Simple Directmedia Layer.
That library has, among other useful stuff, a C++ wrapper for
PhysicsFS.
Here is an API reference for their interface to PhysicsFS.
- SDL_sound comes with a technology
demonstration program, playsound, that is a generalized
sound file playback program. playsound can use PhysicsFS to
stream audio out of archive files on-the-fly.
- Falling Block Game is
a Tetris-style game that uses PhysicsFS under the hood.
- Excido is a 3D arcade
game using PhysicsFS.
- Tales of Middle Earth is an
Angband-based RPG that uses PhysicsFS.
- Dead Meat is a
Bomberman clone with PhysicsFS support.
- netPanzer, a
multiplayer tactical warfare game, utilizes PhysicsFS.
- Z-Raid is
a River Raid clone using PhysicsFS on PocketPC devices!
- Final Frontier Trader
is a 2D single player space strategy, combat, and trading game
powered by PhysicsFS.
- Yac3De
is a 3D engine that is using PhysicsFS to access Doom3 pakfiles
in order to load their maps.
- The maya2q3 plugin uses PhysicsFS to load
shader resources from Quake 3 packages.
- MindBender uses PhysicsFS
for resource management.
- Lincity-NG is a highly-polished SimCity clone that makes use of PhysicsFS.
- Project Xenocide uses PhysicsFS for their data management.
- Warzone 2100 makes use of PhysicsFS so modders can use standard .zip processing utilities.
- SuperTux is a side-scroller using PhysicsFS.
- The Mana World makes use of PhysicsFS.
- OpenAnno is using PhysicsFS.
- Probably other software uses PhysicsFS. If you know of one,
drop me a line.
Operating Systems and distros known to provide PhysicsFS:
What works:
- Support for .ZIP files (PkZip/Info-ZIP/WinZip compatible).
- 1.1 only: support for .7z files (7zip/lzma).
- Support for the Build Engine's GRP format.
- Support for Quake 1 and Quake 2's PAK file format.
- Support for Descent 1 and Descent 2's HOG file format.
- Support for Descent 1 and Descent 2's MVL file format.
- Support for Doom WAD files.
- Support for access to the native filesystem.
- 1.1 only: Fully supports Unicode filenames.
- Compiles/runs on GNU/Linux (x86, PPC, MIPS, Sparc, Alpha, Itanium, and x86-64 tested; gcc).
- Compiles/runs on Windows NT/95/98/ME/2K/XP/Vista/etc (x86 tested;
Visual Studio 6.0, Visual Studio .NET and Cygwin).
- 1.0 only: Compiles/runs on MacOS 8/9 (PPC tested; CodeWarrior 6).
- Compiles/runs on Darwin/MacOS X (PPC tested; gcc).
- Compiles/runs on BeOS (x86 tested; gcc).
- Compiles/runs on FreeBSD (x86 and Alpha tested; gcc).
- Compiles/runs on OpenBSD (x86 and Alpha tested; gcc).
- Compiles/runs on AtheOS (x86 tested; gcc).
- Compiles/runs on OS/2 Warp (x86 tested; EMX).
- Compiles/runs on Atari MiNT (68k tested; gcc).
- Compiles/runs on Solaris.
- Compiles/runs on Microsoft PocketPC.
- May compile and run elsewhere with little to no modification.
Success stories and patches are
welcome.
What doesn't work:
- Other stuff in the TODO file.
- Contributions of other ports are, of course,
welcome.
License:
PhysicsFS is licensed under the
zlib license.
Documentation:
-
A Doxygen-generated API reference
can be found here (or
here for the development branch). You can generate your own
HTML, manpage, LaTeX, RTF, etc documents with this program; download
the PhysicsFS source and use the included Doxyfile.
-
Some kind folks put together a brief
PhysicsFS tutorial.
Downloads:
Prepackaged source code:
- Here is the download directory. You can
find official source code releases here. ".tar.gz" files are like
ZIP files, and can be unarchived by WinZip and Stuffit Expander.
The CHANGELOG file lists all code revisions up to the latest
release (but svn has newer stuff; see below).
- We no longer do binary packages for several reasons. Please
build from source.
Downloading with Subversion:
PhysicsFS's source code may be downloaded using
Subversion. "Svn" allows
you to get up-to-the-minute fixes and enhancements; as a developer works
on a source tree, you can use svn to mirror that source tree instead of
waiting for an official release. Please look at the
Subversion website
for more information on using svn, where you can also download
software for MacOS, Windows, and Unix systems.
PhysicsFS is no longer hosted in a CVS repository. You have to use svn
or wait for an official release.
Here is the web interface to PhysicsFS's svn repository.
To download PhysicsFS via svn:
svn co svn://svn.icculus.org/physfs/trunk/ physfs
...or, for the stable (non-development) branch:
svn co svn://svn.icculus.org/physfs/branches/stable-1.0/ physfs-stable-1.0
Mailing list:
There is a mailing list for PhysicsFS available. To subscribe,
send a blank email to
physfs-subscribe@icculus.org.
To send mail to the list, write to
physfs@icculus.org.
Page maintained by
Ryan C. Gordon.