Remove __PHYSFS_setError(), use the new public API instead.
--- a/src/archiver_dir.c Fri Nov 30 12:43:56 2012 -0500
+++ b/src/archiver_dir.c Fri Nov 30 12:49:25 2012 -0500
@@ -94,7 +94,7 @@
const PHYSFS_ErrorCode err = PHYSFS_getLastErrorCode();
PHYSFS_Stat statbuf;
__PHYSFS_platformStat(f, &statbuf);
- __PHYSFS_setError(err);
+ PHYSFS_setErrorCode(err);
} /* if */
__PHYSFS_smallFree(f);
--- a/src/archiver_lzma.c Fri Nov 30 12:43:56 2012 -0500
+++ b/src/archiver_lzma.c Fri Nov 30 12:49:25 2012 -0500
@@ -291,25 +291,25 @@
case SZ_OK: /* Same as LZMA_RESULT_OK */
break;
case SZE_DATA_ERROR: /* Same as LZMA_RESULT_DATA_ERROR */
- __PHYSFS_setError(PHYSFS_ERR_CORRUPT); /*!!!FIXME: was "PHYSFS_ERR_DATA_ERROR" */
+ PHYSFS_setErrorCode(PHYSFS_ERR_CORRUPT); /*!!!FIXME: was "PHYSFS_ERR_DATA_ERROR" */
break;
case SZE_OUTOFMEMORY:
- __PHYSFS_setError(PHYSFS_ERR_OUT_OF_MEMORY);
+ PHYSFS_setErrorCode(PHYSFS_ERR_OUT_OF_MEMORY);
break;
case SZE_CRC_ERROR:
- __PHYSFS_setError(PHYSFS_ERR_CORRUPT);
+ PHYSFS_setErrorCode(PHYSFS_ERR_CORRUPT);
break;
case SZE_NOTIMPL:
- __PHYSFS_setError(PHYSFS_ERR_UNSUPPORTED);
+ PHYSFS_setErrorCode(PHYSFS_ERR_UNSUPPORTED);
break;
case SZE_FAIL:
- __PHYSFS_setError(PHYSFS_ERR_OTHER_ERROR); /* !!! FIXME: right? */
+ PHYSFS_setErrorCode(PHYSFS_ERR_OTHER_ERROR); /* !!! FIXME: right? */
break;
case SZE_ARCHIVE_ERROR:
- __PHYSFS_setError(PHYSFS_ERR_CORRUPT); /* !!! FIXME: right? */
+ PHYSFS_setErrorCode(PHYSFS_ERR_CORRUPT); /* !!! FIXME: right? */
break;
default:
- __PHYSFS_setError(PHYSFS_ERR_OTHER_ERROR);
+ PHYSFS_setErrorCode(PHYSFS_ERR_OTHER_ERROR);
} /* switch */
return rc;
--- a/src/archiver_zip.c Fri Nov 30 12:43:56 2012 -0500
+++ b/src/archiver_zip.c Fri Nov 30 12:49:25 2012 -0500
@@ -163,7 +163,7 @@
*/
static int zlib_err(const int rc)
{
- __PHYSFS_setError(zlib_error_code(rc));
+ PHYSFS_setErrorCode(zlib_error_code(rc));
return rc;
} /* zlib_err */
--- a/src/physfs.c Fri Nov 30 12:43:56 2012 -0500
+++ b/src/physfs.c Fri Nov 30 12:49:25 2012 -0500
@@ -585,7 +585,7 @@
if (ecd.errcode)
{
- __PHYSFS_setError(ecd.errcode);
+ PHYSFS_setErrorCode(ecd.errcode);
return NULL;
} /* if */
@@ -697,37 +697,6 @@
} /* findErrorForCurrentThread */
-void __PHYSFS_setError(const PHYSFS_ErrorCode errcode)
-{
- ErrState *err;
-
- if (!errcode)
- return;
-
- err = findErrorForCurrentThread();
- if (err == NULL)
- {
- err = (ErrState *) allocator.Malloc(sizeof (ErrState));
- if (err == NULL)
- return; /* uhh...? */
-
- memset(err, '\0', sizeof (ErrState));
- err->tid = __PHYSFS_platformGetThreadID();
-
- if (errorLock != NULL)
- __PHYSFS_platformGrabMutex(errorLock);
-
- err->next = errorStates;
- errorStates = err;
-
- if (errorLock != NULL)
- __PHYSFS_platformReleaseMutex(errorLock);
- } /* if */
-
- err->code = errcode;
-} /* __PHYSFS_setError */
-
-
/* this doesn't reset the error state. */
static inline PHYSFS_ErrorCode currentErrorCode(void)
{
@@ -784,9 +753,34 @@
} /* PHYSFS_getErrorByCode */
-void PHYSFS_setErrorCode(PHYSFS_ErrorCode code)
+void PHYSFS_setErrorCode(PHYSFS_ErrorCode errcode)
{
- __PHYSFS_setError(code);
+ ErrState *err;
+
+ if (!errcode)
+ return;
+
+ err = findErrorForCurrentThread();
+ if (err == NULL)
+ {
+ err = (ErrState *) allocator.Malloc(sizeof (ErrState));
+ if (err == NULL)
+ return; /* uhh...? */
+
+ memset(err, '\0', sizeof (ErrState));
+ err->tid = __PHYSFS_platformGetThreadID();
+
+ if (errorLock != NULL)
+ __PHYSFS_platformGrabMutex(errorLock);
+
+ err->next = errorStates;
+ errorStates = err;
+
+ if (errorLock != NULL)
+ __PHYSFS_platformReleaseMutex(errorLock);
+ } /* if */
+
+ err->code = errcode;
} /* PHYSFS_setErrorCode */
@@ -1191,7 +1185,7 @@
initialized = 1;
/* This makes sure that the error subsystem is initialized. */
- __PHYSFS_setError(PHYSFS_getLastErrorCode());
+ PHYSFS_setErrorCode(PHYSFS_getLastErrorCode());
return 1;
--- a/src/physfs_internal.h Fri Nov 30 12:43:56 2012 -0500
+++ b/src/physfs_internal.h Fri Nov 30 12:49:25 2012 -0500
@@ -127,16 +127,6 @@
/* The latest supported PHYSFS_Archiver::version value. */
#define CURRENT_PHYSFS_ARCHIVER_API_VERSION 0
-/* !!! FIXME: update this documentation.
- * Call this to set the message returned by PHYSFS_getLastError().
- * Please only use the ERR_* constants above, or add new constants to the
- * above group, but I want these all in one place.
- *
- * Calling this with a NULL argument is a safe no-op.
- */
-void __PHYSFS_setError(const PHYSFS_ErrorCode err);
-
-
/* This byteorder stuff was lifted from SDL. http://www.libsdl.org/ */
#define PHYSFS_LIL_ENDIAN 1234
#define PHYSFS_BIG_ENDIAN 4321
@@ -186,14 +176,14 @@
#define ERRPASS PHYSFS_ERR_OK
/* These get used all over for lessening code clutter. */
-#define BAIL_MACRO(e, r) do { if (e) __PHYSFS_setError(e); return r; } while (0)
-#define BAIL_IF_MACRO(c, e, r) do { if (c) { if (e) __PHYSFS_setError(e); return r; } } while (0)
-#define BAIL_MACRO_MUTEX(e, m, r) do { if (e) __PHYSFS_setError(e); __PHYSFS_platformReleaseMutex(m); return r; } while (0)
-#define BAIL_IF_MACRO_MUTEX(c, e, m, r) do { if (c) { if (e) __PHYSFS_setError(e); __PHYSFS_platformReleaseMutex(m); return r; } } while (0)
-#define GOTO_MACRO(e, g) do { if (e) __PHYSFS_setError(e); goto g; } while (0)
-#define GOTO_IF_MACRO(c, e, g) do { if (c) { if (e) __PHYSFS_setError(e); goto g; } } while (0)
-#define GOTO_MACRO_MUTEX(e, m, g) do { if (e) __PHYSFS_setError(e); __PHYSFS_platformReleaseMutex(m); goto g; } while (0)
-#define GOTO_IF_MACRO_MUTEX(c, e, m, g) do { if (c) { if (e) __PHYSFS_setError(e); __PHYSFS_platformReleaseMutex(m); goto g; } } while (0)
+#define BAIL_MACRO(e, r) do { if (e) PHYSFS_setErrorCode(e); return r; } while (0)
+#define BAIL_IF_MACRO(c, e, r) do { if (c) { if (e) PHYSFS_setErrorCode(e); return r; } } while (0)
+#define BAIL_MACRO_MUTEX(e, m, r) do { if (e) PHYSFS_setErrorCode(e); __PHYSFS_platformReleaseMutex(m); return r; } while (0)
+#define BAIL_IF_MACRO_MUTEX(c, e, m, r) do { if (c) { if (e) PHYSFS_setErrorCode(e); __PHYSFS_platformReleaseMutex(m); return r; } } while (0)
+#define GOTO_MACRO(e, g) do { if (e) PHYSFS_setErrorCode(e); goto g; } while (0)
+#define GOTO_IF_MACRO(c, e, g) do { if (c) { if (e) PHYSFS_setErrorCode(e); goto g; } } while (0)
+#define GOTO_MACRO_MUTEX(e, m, g) do { if (e) PHYSFS_setErrorCode(e); __PHYSFS_platformReleaseMutex(m); goto g; } while (0)
+#define GOTO_IF_MACRO_MUTEX(c, e, m, g) do { if (c) { if (e) PHYSFS_setErrorCode(e); __PHYSFS_platformReleaseMutex(m); goto g; } } while (0)
#define __PHYSFS_ARRAYLEN(x) ( (sizeof (x)) / (sizeof (x[0])) )
@@ -365,7 +355,7 @@
* a unique file handle; this is frequently employed to prevent race
* conditions in the archivers.
*
- * Call __PHYSFS_setError() and return (NULL) if the file can't be opened.
+ * Call PHYSFS_setErrorCode() and return (NULL) if the file can't be opened.
*/
void *__PHYSFS_platformOpenRead(const char *filename);
@@ -382,7 +372,7 @@
*
* Opening a file for write multiple times has undefined results.
*
- * Call __PHYSFS_setError() and return (NULL) if the file can't be opened.
+ * Call PHYSFS_setErrorCode() and return (NULL) if the file can't be opened.
*/
void *__PHYSFS_platformOpenWrite(const char *filename);
@@ -400,7 +390,7 @@
*
* Opening a file for append multiple times has undefined results.
*
- * Call __PHYSFS_setError() and return (NULL) if the file can't be opened.
+ * Call PHYSFS_setErrorCode() and return (NULL) if the file can't be opened.
*/
void *__PHYSFS_platformOpenAppend(const char *filename);
@@ -412,7 +402,7 @@
* immediately after those bytes.
* On success, return (len) and position the file pointer immediately past
* the end of the last read byte. Return (-1) if there is a catastrophic
- * error, and call __PHYSFS_setError() to describe the problem; the file
+ * error, and call PHYSFS_setErrorCode() to describe the problem; the file
* pointer should not move in such a case. A partial read is success; only
* return (-1) on total failure; presumably, the next read call after a
* partial read will fail as such.
@@ -425,7 +415,7 @@
* 8-bit bytes from the area pointed to by (buffer). If there is a problem,
* return the number of bytes written, and position the file pointer
* immediately after those bytes. Return (-1) if there is a catastrophic
- * error, and call __PHYSFS_setError() to describe the problem; the file
+ * error, and call PHYSFS_setErrorCode() to describe the problem; the file
* pointer should not move in such a case. A partial write is success; only
* return (-1) on total failure; presumably, the next write call after a
* partial write will fail as such.
@@ -441,7 +431,7 @@
*
* Not all file types can seek; this is to be expected by the caller.
*
- * On error, call __PHYSFS_setError() and return zero. On success, return
+ * On error, call PHYSFS_setErrorCode() and return zero. On success, return
* a non-zero value.
*/
int __PHYSFS_platformSeek(void *opaque, PHYSFS_uint64 pos);
@@ -454,7 +444,7 @@
*
* Not all file types can "tell"; this is to be expected by the caller.
*
- * On error, call __PHYSFS_setError() and return -1. On success, return >= 0.
+ * On error, call PHYSFS_setErrorCode() and return -1. On success, return >= 0.
*/
PHYSFS_sint64 __PHYSFS_platformTell(void *opaque);
@@ -465,7 +455,7 @@
* The caller expects that this information may not be available for all
* file types on all platforms.
*
- * Return -1 if you can't do it, and call __PHYSFS_setError(). Otherwise,
+ * Return -1 if you can't do it, and call PHYSFS_setErrorCode(). Otherwise,
* return the file length in 8-bit bytes.
*/
PHYSFS_sint64 __PHYSFS_platformFileLength(void *handle);
@@ -609,7 +599,7 @@
* timing out! We're talking major system errors; block until the mutex
* is available otherwise.)
*
- * _DO NOT_ call __PHYSFS_setError() in here! Since setError calls this
+ * _DO NOT_ call PHYSFS_setErrorCode() in here! Since setErrorCode calls this
* function, you'll cause an infinite recursion. This means you can't
* use the BAIL_*MACRO* macros, either.
*/
@@ -621,7 +611,7 @@
* been released, the next thread in line to grab the mutex (if any) may
* proceed.
*
- * _DO NOT_ call __PHYSFS_setError() in here! Since setError calls this
+ * _DO NOT_ call PHYSFS_setErrorCode() in here! Since setErrorCode calls this
* function, you'll cause an infinite recursion. This means you can't
* use the BAIL_*MACRO* macros, either.
*/
--- a/src/platform_windows.c Fri Nov 30 12:43:56 2012 -0500
+++ b/src/platform_windows.c Fri Nov 30 12:49:25 2012 -0500
@@ -369,7 +369,7 @@
} /* while */
if ((ptr == modpath) && (*ptr != '\\'))
- __PHYSFS_setError(PHYSFS_ERR_OTHER_ERROR); /* oh well. */
+ PHYSFS_setErrorCode(PHYSFS_ERR_OTHER_ERROR); /* oh well. */
else
{
*(ptr+1) = '\0'; /* chop off filename. */