PHYSFS_init
Initialize the PhysicsFS library.
Defined in <physfs.h>
Syntax
int PHYSFS_init(const char *argv0);
Function Parameters
| const char * |
argv0 |
the argv[0] string passed to your program's mainline, or some other
system-specific values. |
Return Value
(int) Returns nonzero on success, zero on error. Specifics of the
error can be gleaned from PHYSFS_getLastError().
This must be called before any other PhysicsFS function.
This should be called prior to any attempts to change your process's
current working directory.
argv0 may be NULL on most platforms (such as ones
without a standard main() function), but you should always try to pass
something in here when reasonable. Many Unix-like systems need
to pass argv[0] from main() in here. However several platforms have
special needs:
- On Android, argv0 should be a non-NULL pointer to a PHYSFS_AndroidInit struct. This struct
must hold a valid JNIEnv * and a JNI jobject of a Context (either the
application context or the current Activity is fine). Both are cast to a
void * so we don't need jni.h included wherever physfs.h is. PhysicsFS
uses these objects to query some system details. PhysicsFS does not hold
a reference to the JNIEnv or Context past the call to PHYSFS_init(). If you pass a NULL here, PHYSFS_init can still succeed, but PHYSFS_getBaseDir() and PHYSFS_getPrefDir() will be incorrect.
- On Playdate, argv0 should be a non-NULL pointer to a PlaydateAPI
struct. PhysicsFS uses this object for system-level access and will hold
it until PHYSFS_deinit is called. If you
pass a NULL here, PhysicsFS will crash.
- On libretro, argv0 should be a non-NULL pointer to the
retro_environment_t callback. PhysicsFS will use this callback to get
libretro's virtual file system interface, along with any other related
directory paths.
If argv0 is NULL, PhysicsFS will attempt to work without
it, if possible.
Thread Safety
This function is not thread safe.
Version
This function is available since PhysicsFS 1.0.0.
See Also
CategoryAPI, CategoryAPIFunction, CategoryPhysicsFS