[physfs] win32: Using PhysFS from inside a DLL?
tree at stain.org
Wed Sep 3 20:38:04 EDT 2003
> > different from an exe, except for the init string. We use it as a dll
> > fine. We don't have an exe as our app is mostly in java, so using dlls
> > our only option.
> Where does PhysFS think your base directory is when used in this method,
> out of curiousity? The location of the Java virtual machine .exe, I
> assume? Does that cause you problems (i.e. - if possible, should we strive
> to detect this condition and select the directory where the .class/.jar is
> located instead? If that's possible, is that even a correct solution?) ?
By default the base directory would be the location of java.exe, yes. We
avoid any problem with this as the installer for our app makes a stub exe
file which invokes the Java Virtual Machine without going through java.exe,
so the base directory is where this exe is. We always use relative paths to
define our physfs search paths. This is fine in the development environment
too as you can just set the working directory in any IDE. This isn't really
a total solution for java usage though
Ideally the physfs base directory should be where the jar exists which
contains the main class. In java you would have to call something like:
URL jarLocation =
where MAINCLASS is the name of the class you invoke. I think this should
work for jars and for a .class file hierarchy.
If you called this from C, through JNI it should work too. I don't have time
to write you a bit of code to do this just now (less than two weeks to
launching our website and all), but if you like I'll write it when I get
time after that.
That said, most people who use Java wouldn't need to use Physfs as the java
filesystem includes jar files (glorified zip files) like directories
natively. We use Physfs so we have a single file (a jar), which contains all
custom code and data for each of our tracks, which we can access from the
Java and the C side. This is a pretty unusual requirement, but not unique.
More information about the physfs