Просмотр исходного кода

Added __PHYSFS_platformInit() and __PHYSFS_platformDeinit().

Ryan C. Gordon 24 лет назад
Родитель
Сommit
419d5cd017
4 измененных файлов с 37 добавлено и 0 удалено
  1. 1 0
      CHANGELOG
  2. 2 0
      physfs.c
  3. 21 0
      physfs_internal.h
  4. 13 0
      platform/unix.c

+ 1 - 0
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)
 

+ 2 - 0
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);

+ 21 - 0
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().

+ 13 - 0
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)