From 419d5cd01790224a1c1967188584126b89bd9e91 Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Sun, 24 Mar 2002 06:36:48 +0000 Subject: [PATCH] Added __PHYSFS_platformInit() and __PHYSFS_platformDeinit(). --- CHANGELOG | 1 + physfs.c | 2 ++ physfs_internal.h | 21 +++++++++++++++++++++ platform/unix.c | 13 +++++++++++++ 4 files changed, 37 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index 8077ccba..feefa2ac 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -70,6 +70,7 @@ "write" functions to get data from a "const" buffer. Added an "extras" dir, which currently contains PhysFS->SDL_RWops glue code. 03202002 - Patched platform/win32.c to compile. +03242002 - Added __PHYSFS_platformInit() and __PHYSFS_platformDeinit(). --ryan. (icculus@clutteredmind.org) diff --git a/physfs.c b/physfs.c index 6e2f2067..1582f7ce 100644 --- a/physfs.c +++ b/physfs.c @@ -362,6 +362,7 @@ int PHYSFS_init(const char *argv0) BAIL_IF_MACRO(initialized, ERR_IS_INITIALIZED, 0); BAIL_IF_MACRO(argv0 == NULL, ERR_INVALID_ARGUMENT, 0); + BAIL_IF_MACRO(!__PHYSFS_platformInit(), NULL, 0); baseDir = calculateBaseDir(argv0); BAIL_IF_MACRO(baseDir == NULL, NULL, 0); @@ -438,6 +439,7 @@ static void freeSearchPath(void) int PHYSFS_deinit(void) { BAIL_IF_MACRO(!initialized, ERR_NOT_INITIALIZED, 0); + BAIL_IF_MACRO(!__PHYSFS_platformDeinit(), NULL, 0); closeFileHandleList(&openWriteList); BAIL_IF_MACRO(!PHYSFS_setWriteDir(NULL), ERR_FILES_STILL_OPEN, 0); diff --git a/physfs_internal.h b/physfs_internal.h index 4b13740c..7cac9cd4 100644 --- a/physfs_internal.h +++ b/physfs_internal.h @@ -319,6 +319,27 @@ int __PHYSFS_verifySecurity(DirHandle *h, const char *fname); */ extern const char *__PHYSFS_platformDirSeparator; + +/* + * Initialize the platform. This is called when PHYSFS_init() is called from + * the application. You can use this to (for example) determine what version + * of Windows you're running. + * + * Return zero if there was a catastrophic failure (which prevents you from + * functioning at all), and non-zero otherwise. + */ +int __PHYSFS_platformInit(void); + +/* + * Deinitialize the platform. This is called when PHYSFS_deinit() is called + * from the application. You can use this to clean up anything you've + * allocated in your platform driver. + * + * Return zero if there was a catastrophic failure (which prevents you from + * functioning at all), and non-zero otherwise. + */ +int __PHYSFS_platformDeinit(void); + /* * Platform implementation of PHYSFS_getCdRomDirs()... * See physfs.h. The retval should be freeable via PHYSFS_freeList(). diff --git a/platform/unix.c b/platform/unix.c index 17831dae..5b58a64a 100644 --- a/platform/unix.c +++ b/platform/unix.c @@ -59,6 +59,19 @@ const char *__PHYSFS_platformDirSeparator = "/"; +int __PHYSFS_platformInit(void) +{ + return(1); /* always succeed. */ +} /* __PHYSFS_platformInit */ + + +int __PHYSFS_platformDeinit(void) +{ + return(1); /* always succeed. */ +} /* __PHYSFS_platformDeinit */ + + + #if (defined __DARWIN__) char **__PHYSFS_platformDetectAvailableCDs(void)