SDL: Updated PhysFS to v2.0.3
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
repo: 7672c9962ce627edaaa67ff54fe4ad8f9a46dc2b
|
||||
node: 92a35b8603186c536e4cc126458dfc2d2809b19c
|
||||
node: f94eec5e90540889a42c34a27931b8266f4af52c
|
||||
branch: stable-2.0
|
||||
latesttag: release-2.0.2
|
||||
latesttag: release-2.0.3
|
||||
latesttagdistance: 1
|
||||
|
||||
@@ -14,3 +14,4 @@ fe0c1d6f40afa6fca09a277a1ade59231f16c66f release-1.1.1
|
||||
df04959950eb3830c39adfa983789f70f86062d7 release-1.1.0
|
||||
94771621792f838aa4cacf9a1e1f4f86c1cb0711 release-2.0.1
|
||||
236afd18dd8cae34adb9897024bdcecc1dc8ca5d release-2.0.2
|
||||
bf155bd2127befa399105194e13737d7c3496be0 release-2.0.3
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
CMAKE_MINIMUM_REQUIRED(VERSION 2.4)
|
||||
|
||||
PROJECT(PhysicsFS)
|
||||
SET(PHYSFS_VERSION 2.0.2)
|
||||
SET(PHYSFS_VERSION 2.0.3)
|
||||
|
||||
# Increment this if/when we break backwards compatibility.
|
||||
SET(PHYSFS_SOVERSION 1)
|
||||
@@ -21,6 +21,11 @@ IF(APPLE AND NOT MACOSX)
|
||||
SET(MACOSX TRUE)
|
||||
ENDIF(APPLE AND NOT MACOSX)
|
||||
|
||||
# For now, Haiku and BeOS are the same, as far as the build system cares.
|
||||
IF(HAIKU AND NOT BEOS)
|
||||
SET(BEOS TRUE)
|
||||
ENDIF(HAIKU AND NOT BEOS)
|
||||
|
||||
INCLUDE(CheckIncludeFile)
|
||||
INCLUDE(CheckLibraryExists)
|
||||
INCLUDE(CheckCSourceCompiles)
|
||||
@@ -303,20 +308,19 @@ IF(PHYSFS_BUILD_TEST)
|
||||
FIND_LIBRARY(CURSES_LIBRARY NAMES curses ncurses)
|
||||
SET(CMAKE_REQUIRED_LIBRARIES ${CURSES_LIBRARY})
|
||||
FIND_LIBRARY(READLINE_LIBRARY readline)
|
||||
FIND_LIBRARY(HISTORY_LIBRARY history)
|
||||
IF(READLINE_LIBRARY AND HISTORY_LIBRARY)
|
||||
IF(READLINE_LIBRARY)
|
||||
SET(HAVE_SYSTEM_READLINE TRUE)
|
||||
SET(TEST_PHYSFS_LIBS ${TEST_PHYSFS_LIBS} ${READLINE_LIBRARY} ${CURSES_LIBRARY})
|
||||
INCLUDE_DIRECTORIES(${READLINE_H} ${HISTORY_H})
|
||||
ADD_DEFINITIONS(-DPHYSFS_HAVE_READLINE=1)
|
||||
ENDIF(READLINE_LIBRARY AND HISTORY_LIBRARY)
|
||||
ENDIF(READLINE_LIBRARY)
|
||||
ENDIF(READLINE_H AND HISTORY_H)
|
||||
ADD_EXECUTABLE(test_physfs test/test_physfs.c)
|
||||
TARGET_LINK_LIBRARIES(test_physfs ${PHYSFS_LIB_TARGET} ${TEST_PHYSFS_LIBS} ${OTHER_LDFLAGS})
|
||||
SET(PHYSFS_INSTALL_TARGETS ${PHYSFS_INSTALL_TARGETS} ";test_physfs")
|
||||
ENDIF(PHYSFS_BUILD_TEST)
|
||||
|
||||
OPTION(PHYSFS_BUILD_WX_TEST "Build wxWidgets test program." TRUE)
|
||||
OPTION(PHYSFS_BUILD_WX_TEST "Build wxWidgets test program." FALSE)
|
||||
MARK_AS_ADVANCED(PHYSFS_BUILD_WX_TEST)
|
||||
IF(PHYSFS_BUILD_WX_TEST)
|
||||
SET(wxWidgets_USE_LIBS base core adv)
|
||||
@@ -342,16 +346,32 @@ INSTALL(FILES physfs.h DESTINATION include)
|
||||
|
||||
FIND_PACKAGE(Doxygen)
|
||||
IF(DOXYGEN_FOUND)
|
||||
ADD_CUSTOM_TARGET(docs ${DOXYGEN_EXECUTABLE} COMMENT "Building documentation")
|
||||
SET(PHYSFS_OUTPUT_DOXYFILE "${CMAKE_CURRENT_BINARY_DIR}/Doxyfile")
|
||||
CONFIGURE_FILE(
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile"
|
||||
"${PHYSFS_OUTPUT_DOXYFILE}"
|
||||
COPYONLY
|
||||
)
|
||||
FILE(APPEND "${PHYSFS_OUTPUT_DOXYFILE}" "\n\n# Below auto-generated by cmake...\n\n")
|
||||
FILE(APPEND "${PHYSFS_OUTPUT_DOXYFILE}" "PROJECT_NUMBER = ${PHYSFS_VERSION}\n")
|
||||
FILE(APPEND "${PHYSFS_OUTPUT_DOXYFILE}" "OUTPUT_DIRECTORY = ${CMAKE_CURRENT_BINARY_DIR}/docs\n")
|
||||
FILE(APPEND "${PHYSFS_OUTPUT_DOXYFILE}" "\n# End auto-generated section.\n\n")
|
||||
|
||||
ADD_CUSTOM_TARGET(
|
||||
docs
|
||||
${DOXYGEN_EXECUTABLE} "${PHYSFS_OUTPUT_DOXYFILE}"
|
||||
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
|
||||
COMMENT "Building documentation in 'docs' directory..."
|
||||
)
|
||||
ELSE(DOXYGEN_FOUND)
|
||||
MESSAGE(STATUS "Doxygen not found. You won't be able to build documentation.")
|
||||
ENDIF(DOXYGEN_FOUND)
|
||||
|
||||
IF(UNIX)
|
||||
SET(PHYSFS_TARBALL "${CMAKE_CURRENT_SOURCE_DIR}/../physfs-${PHYSFS_VERSION}.tar.gz")
|
||||
SET(PHYSFS_TARBALL "${CMAKE_CURRENT_SOURCE_DIR}/../physfs-${PHYSFS_VERSION}.tar.bz2")
|
||||
ADD_CUSTOM_TARGET(
|
||||
dist
|
||||
hg archive -t tgz "${PHYSFS_TARBALL}"
|
||||
hg archive -t tbz2 "${PHYSFS_TARBALL}"
|
||||
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
|
||||
COMMENT "Building source tarball '${PHYSFS_TARBALL}'..."
|
||||
)
|
||||
@@ -385,4 +405,3 @@ IF(PHYSFS_BUILD_TEST)
|
||||
ENDIF(PHYSFS_BUILD_TEST)
|
||||
|
||||
# end of CMakeLists.txt ...
|
||||
|
||||
|
||||
@@ -106,6 +106,9 @@ OS/2 updates:
|
||||
Bug fixes:
|
||||
Patrice Mandin
|
||||
|
||||
Bug fixes:
|
||||
Lauri Kasanen
|
||||
|
||||
Other stuff:
|
||||
Your name here! Patches go to icculus@icculus.org ...
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
|
||||
Copyright (c) 2001-2011 Ryan C. Gordon and others.
|
||||
Copyright (c) 2001-2012 Ryan C. Gordon and others.
|
||||
|
||||
This software is provided 'as-is', without any express or implied warranty.
|
||||
In no event will the authors be held liable for any damages arising from
|
||||
|
||||
@@ -245,9 +245,6 @@ static int wad_load_entries(const char *name, int forWriting, WADinfo *info)
|
||||
PHYSFS_uint32 fileCount;
|
||||
PHYSFS_uint32 directoryOffset;
|
||||
WADentry *entry;
|
||||
char lastDirectory[9];
|
||||
|
||||
lastDirectory[8] = 0; /* Make sure lastDirectory stays null-terminated. */
|
||||
|
||||
BAIL_IF_MACRO(!wad_open(name, forWriting, &fh, &fileCount,&directoryOffset), NULL, 0);
|
||||
info->entryCount = fileCount;
|
||||
|
||||
@@ -535,6 +535,8 @@ static ZIPentry *zip_find_entry(ZIPinfo *info, const char *path, int *isDir)
|
||||
|
||||
else /* substring match...might be dir or entry or nothing. */
|
||||
{
|
||||
int i;
|
||||
|
||||
if (isDir != NULL)
|
||||
{
|
||||
*isDir = (thispath[pathlen] == '/');
|
||||
@@ -544,12 +546,27 @@ static ZIPentry *zip_find_entry(ZIPinfo *info, const char *path, int *isDir)
|
||||
|
||||
if (thispath[pathlen] == '\0') /* found entry? */
|
||||
return(&a[middle]);
|
||||
/* adjust search params, try again. */
|
||||
else if (thispath[pathlen] > '/')
|
||||
hi = middle - 1;
|
||||
else
|
||||
lo = middle + 1;
|
||||
} /* if */
|
||||
|
||||
/* substring match; search remaining space to find it... */
|
||||
for (i = lo; i < hi; i++)
|
||||
{
|
||||
thispath = a[i].name;
|
||||
if (strncmp(path, thispath, pathlen) == 0)
|
||||
{
|
||||
if (isDir != NULL)
|
||||
{
|
||||
*isDir = (thispath[pathlen] == '/');
|
||||
if (*isDir)
|
||||
return(NULL);
|
||||
} /* if */
|
||||
|
||||
if (thispath[pathlen] == '\0') /* found entry? */
|
||||
return(&a[i]);
|
||||
} /* if */
|
||||
} /* for */
|
||||
break;
|
||||
|
||||
} /* else */
|
||||
} /* while */
|
||||
|
||||
if (isDir != NULL)
|
||||
@@ -628,6 +645,7 @@ static void zip_expand_symlink_path(char *path)
|
||||
else
|
||||
{
|
||||
prevptr = ptr;
|
||||
ptr++;
|
||||
} /* else */
|
||||
} /* while */
|
||||
} /* zip_expand_symlink_path */
|
||||
|
||||
@@ -405,7 +405,7 @@ typedef struct PHYSFS_Version
|
||||
#ifndef DOXYGEN_SHOULD_IGNORE_THIS
|
||||
#define PHYSFS_VER_MAJOR 2
|
||||
#define PHYSFS_VER_MINOR 0
|
||||
#define PHYSFS_VER_PATCH 2
|
||||
#define PHYSFS_VER_PATCH 3
|
||||
#endif /* DOXYGEN_SHOULD_IGNORE_THIS */
|
||||
|
||||
|
||||
|
||||
@@ -970,7 +970,8 @@ char *__PHYSFS_convertToDependent(const char *prepend,
|
||||
#define PHYSFS_LIL_ENDIAN 1234
|
||||
#define PHYSFS_BIG_ENDIAN 4321
|
||||
|
||||
#if defined(__i386__) || defined(__ia64__) || defined(_M_IX86) || defined(_M_IA64) || \
|
||||
#if defined(__i386__) || defined(__ia64__) || \
|
||||
defined(_M_IX86) || defined(_M_IA64) || defined(_M_X64) || \
|
||||
(defined(__alpha__) || defined(__alpha)) || \
|
||||
defined(__arm__) || defined(ARM) || \
|
||||
(defined(__mips__) && defined(__MIPSEL__)) || \
|
||||
@@ -1225,8 +1226,7 @@ int __PHYSFS_platformSeek(void *opaque, PHYSFS_uint64 pos);
|
||||
*
|
||||
* Not all file types can "tell"; this is to be expected by the caller.
|
||||
*
|
||||
* On error, call __PHYSFS_setError() and return zero. On success, return
|
||||
* a non-zero value.
|
||||
* On error, call __PHYSFS_setError() and return -1. On success, return >= 0.
|
||||
*/
|
||||
PHYSFS_sint64 __PHYSFS_platformTell(void *opaque);
|
||||
|
||||
@@ -1305,12 +1305,12 @@ char *__PHYSFS_platformGetUserName(void);
|
||||
char *__PHYSFS_platformGetUserDir(void);
|
||||
|
||||
/*
|
||||
* Return a number that uniquely identifies the current thread.
|
||||
* On a platform without threading, (1) will suffice. These numbers are
|
||||
* Return a pointer that uniquely identifies the current thread.
|
||||
* On a platform without threading, (0x1) will suffice. These numbers are
|
||||
* arbitrary; the only requirement is that no two threads have the same
|
||||
* number.
|
||||
* pointer.
|
||||
*/
|
||||
PHYSFS_uint64 __PHYSFS_platformGetThreadID(void);
|
||||
void *__PHYSFS_platformGetThreadID(void);
|
||||
|
||||
/*
|
||||
* Return non-zero if filename (in platform-dependent notation) exists.
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
# endif
|
||||
#elif defined(macintosh)
|
||||
# error Classic Mac OS support was dropped from PhysicsFS 2.0. Move to OS X.
|
||||
#elif defined(unix)
|
||||
#elif defined(unix) || defined(__unix__)
|
||||
# define PHYSFS_PLATFORM_UNIX
|
||||
# define PHYSFS_PLATFORM_POSIX
|
||||
#else
|
||||
|
||||
@@ -43,7 +43,7 @@ typedef struct __PHYSFS_FILEHANDLE__
|
||||
|
||||
typedef struct __PHYSFS_ERRMSGTYPE__
|
||||
{
|
||||
PHYSFS_uint64 tid;
|
||||
void *tid;
|
||||
int errorAvailable;
|
||||
char errorString[80];
|
||||
struct __PHYSFS_ERRMSGTYPE__ *next;
|
||||
@@ -94,7 +94,7 @@ static const PHYSFS_ArchiveInfo *supported_types[] =
|
||||
NULL
|
||||
};
|
||||
|
||||
static const PHYSFS_Archiver *archivers[] =
|
||||
static const PHYSFS_Archiver * const archivers[] =
|
||||
{
|
||||
&__PHYSFS_Archiver_DIR,
|
||||
#if (defined PHYSFS_SUPPORTS_ZIP)
|
||||
@@ -261,14 +261,15 @@ void __PHYSFS_sort(void *entries, PHYSFS_uint32 max,
|
||||
* Quicksort w/ Bubblesort fallback algorithm inspired by code from here:
|
||||
* http://www.cs.ubc.ca/spider/harrison/Java/sorting-demo.html
|
||||
*/
|
||||
__PHYSFS_quick_sort(entries, 0, max - 1, cmpfn, swapfn);
|
||||
if (max > 0)
|
||||
__PHYSFS_quick_sort(entries, 0, max - 1, cmpfn, swapfn);
|
||||
} /* __PHYSFS_sort */
|
||||
|
||||
|
||||
static ErrMsg *findErrorForCurrentThread(void)
|
||||
{
|
||||
ErrMsg *i;
|
||||
PHYSFS_uint64 tid;
|
||||
void *tid;
|
||||
|
||||
if (errorLock != NULL)
|
||||
__PHYSFS_platformGrabMutex(errorLock);
|
||||
@@ -416,7 +417,7 @@ static DirHandle *tryOpenDir(const PHYSFS_Archiver *funcs,
|
||||
static DirHandle *openDirectory(const char *d, int forWriting)
|
||||
{
|
||||
DirHandle *retval = NULL;
|
||||
const PHYSFS_Archiver **i;
|
||||
const PHYSFS_Archiver * const *i;
|
||||
const char *ext;
|
||||
|
||||
BAIL_IF_MACRO(!__PHYSFS_platformExists(d), ERR_NO_SUCH_FILE, NULL);
|
||||
|
||||
@@ -63,12 +63,13 @@ static PHYSFS_uint32 utf8codepoint(const char **_str)
|
||||
|
||||
else if (octet < 224) /* two octets */
|
||||
{
|
||||
(*_str)++; /* advance at least one byte in case of an error */
|
||||
octet -= (128+64);
|
||||
octet2 = (PHYSFS_uint32) ((PHYSFS_uint8) *(++str));
|
||||
if ((octet2 & (128+64)) != 128) /* Format isn't 10xxxxxx? */
|
||||
return UNICODE_BOGUS_CHAR_VALUE;
|
||||
|
||||
*_str += 2; /* skip to next possible start of codepoint. */
|
||||
*_str += 1; /* skip to next possible start of codepoint. */
|
||||
retval = ((octet << 6) | (octet2 - 128));
|
||||
if ((retval >= 0x80) && (retval <= 0x7FF))
|
||||
return retval;
|
||||
@@ -76,6 +77,7 @@ static PHYSFS_uint32 utf8codepoint(const char **_str)
|
||||
|
||||
else if (octet < 240) /* three octets */
|
||||
{
|
||||
(*_str)++; // advance at least one byte in case of an error
|
||||
octet -= (128+64+32);
|
||||
octet2 = (PHYSFS_uint32) ((PHYSFS_uint8) *(++str));
|
||||
if ((octet2 & (128+64)) != 128) /* Format isn't 10xxxxxx? */
|
||||
@@ -85,7 +87,7 @@ static PHYSFS_uint32 utf8codepoint(const char **_str)
|
||||
if ((octet3 & (128+64)) != 128) /* Format isn't 10xxxxxx? */
|
||||
return UNICODE_BOGUS_CHAR_VALUE;
|
||||
|
||||
*_str += 3; /* skip to next possible start of codepoint. */
|
||||
*_str += 2; /* skip to next possible start of codepoint. */
|
||||
retval = ( ((octet << 12)) | ((octet2-128) << 6) | ((octet3-128)) );
|
||||
|
||||
/* There are seven "UTF-16 surrogates" that are illegal in UTF-8. */
|
||||
@@ -108,6 +110,7 @@ static PHYSFS_uint32 utf8codepoint(const char **_str)
|
||||
|
||||
else if (octet < 248) /* four octets */
|
||||
{
|
||||
(*_str)++; // advance at least one byte in case of an error
|
||||
octet -= (128+64+32+16);
|
||||
octet2 = (PHYSFS_uint32) ((PHYSFS_uint8) *(++str));
|
||||
if ((octet2 & (128+64)) != 128) /* Format isn't 10xxxxxx? */
|
||||
@@ -121,7 +124,7 @@ static PHYSFS_uint32 utf8codepoint(const char **_str)
|
||||
if ((octet4 & (128+64)) != 128) /* Format isn't 10xxxxxx? */
|
||||
return UNICODE_BOGUS_CHAR_VALUE;
|
||||
|
||||
*_str += 4; /* skip to next possible start of codepoint. */
|
||||
*_str += 3; /* skip to next possible start of codepoint. */
|
||||
retval = ( ((octet << 18)) | ((octet2 - 128) << 12) |
|
||||
((octet3 - 128) << 6) | ((octet4 - 128)) );
|
||||
if ((retval >= 0x10000) && (retval <= 0x10FFFF))
|
||||
@@ -136,6 +139,34 @@ static PHYSFS_uint32 utf8codepoint(const char **_str)
|
||||
|
||||
else if (octet < 252) /* five octets */
|
||||
{
|
||||
(*_str)++; // advance at least one byte in case of an error
|
||||
octet = (PHYSFS_uint32) ((PHYSFS_uint8) *(++str));
|
||||
if ((octet & (128+64)) != 128) /* Format isn't 10xxxxxx? */
|
||||
return UNICODE_BOGUS_CHAR_VALUE;
|
||||
|
||||
octet = (PHYSFS_uint32) ((PHYSFS_uint8) *(++str));
|
||||
if ((octet & (128+64)) != 128) /* Format isn't 10xxxxxx? */
|
||||
return UNICODE_BOGUS_CHAR_VALUE;
|
||||
|
||||
octet = (PHYSFS_uint32) ((PHYSFS_uint8) *(++str));
|
||||
if ((octet & (128+64)) != 128) /* Format isn't 10xxxxxx? */
|
||||
return UNICODE_BOGUS_CHAR_VALUE;
|
||||
|
||||
octet = (PHYSFS_uint32) ((PHYSFS_uint8) *(++str));
|
||||
if ((octet & (128+64)) != 128) /* Format isn't 10xxxxxx? */
|
||||
return UNICODE_BOGUS_CHAR_VALUE;
|
||||
|
||||
*_str += 4; /* skip to next possible start of codepoint. */
|
||||
return UNICODE_BOGUS_CHAR_VALUE;
|
||||
} /* else if */
|
||||
|
||||
else /* six octets */
|
||||
{
|
||||
(*_str)++; // advance at least one byte in case of an error
|
||||
octet = (PHYSFS_uint32) ((PHYSFS_uint8) *(++str));
|
||||
if ((octet & (128+64)) != 128) /* Format isn't 10xxxxxx? */
|
||||
return UNICODE_BOGUS_CHAR_VALUE;
|
||||
|
||||
octet = (PHYSFS_uint32) ((PHYSFS_uint8) *(++str));
|
||||
if ((octet & (128+64)) != 128) /* Format isn't 10xxxxxx? */
|
||||
return UNICODE_BOGUS_CHAR_VALUE;
|
||||
@@ -156,32 +187,6 @@ static PHYSFS_uint32 utf8codepoint(const char **_str)
|
||||
return UNICODE_BOGUS_CHAR_VALUE;
|
||||
} /* else if */
|
||||
|
||||
else /* six octets */
|
||||
{
|
||||
octet = (PHYSFS_uint32) ((PHYSFS_uint8) *(++str));
|
||||
if ((octet & (128+64)) != 128) /* Format isn't 10xxxxxx? */
|
||||
return UNICODE_BOGUS_CHAR_VALUE;
|
||||
|
||||
octet = (PHYSFS_uint32) ((PHYSFS_uint8) *(++str));
|
||||
if ((octet & (128+64)) != 128) /* Format isn't 10xxxxxx? */
|
||||
return UNICODE_BOGUS_CHAR_VALUE;
|
||||
|
||||
octet = (PHYSFS_uint32) ((PHYSFS_uint8) *(++str));
|
||||
if ((octet & (128+64)) != 128) /* Format isn't 10xxxxxx? */
|
||||
return UNICODE_BOGUS_CHAR_VALUE;
|
||||
|
||||
octet = (PHYSFS_uint32) ((PHYSFS_uint8) *(++str));
|
||||
if ((octet & (128+64)) != 128) /* Format isn't 10xxxxxx? */
|
||||
return UNICODE_BOGUS_CHAR_VALUE;
|
||||
|
||||
octet = (PHYSFS_uint32) ((PHYSFS_uint8) *(++str));
|
||||
if ((octet & (128+64)) != 128) /* Format isn't 10xxxxxx? */
|
||||
return UNICODE_BOGUS_CHAR_VALUE;
|
||||
|
||||
*_str += 6; /* skip to next possible start of codepoint. */
|
||||
return UNICODE_BOGUS_CHAR_VALUE;
|
||||
} /* else if */
|
||||
|
||||
return UNICODE_BOGUS_CHAR_VALUE;
|
||||
} /* utf8codepoint */
|
||||
|
||||
|
||||
@@ -197,9 +197,9 @@ char *__PHYSFS_platformCalcBaseDir(const char *argv0)
|
||||
} /* __PHYSFS_platformCalcBaseDir */
|
||||
|
||||
|
||||
PHYSFS_uint64 __PHYSFS_platformGetThreadID(void)
|
||||
void *__PHYSFS_platformGetThreadID(void)
|
||||
{
|
||||
return((PHYSFS_uint64) find_thread(NULL));
|
||||
return((void *) find_thread(NULL));
|
||||
} /* __PHYSFS_platformGetThreadID */
|
||||
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
#include <IOKit/storage/IOCDMedia.h>
|
||||
#include <IOKit/storage/IODVDMedia.h>
|
||||
#include <sys/mount.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
/* Seems to get defined in some system header... */
|
||||
#ifdef Free
|
||||
@@ -219,12 +220,15 @@ static char *convertCFString(CFStringRef cfstr)
|
||||
char *__PHYSFS_platformCalcBaseDir(const char *argv0)
|
||||
{
|
||||
ProcessSerialNumber psn = { 0, kCurrentProcess };
|
||||
struct stat statbuf;
|
||||
FSRef fsref;
|
||||
CFRange cfrange;
|
||||
CFURLRef cfurl = NULL;
|
||||
CFStringRef cfstr = NULL;
|
||||
CFMutableStringRef cfmutstr = NULL;
|
||||
char *retval = NULL;
|
||||
char *cstr = NULL;
|
||||
int rc = 0;
|
||||
|
||||
BAIL_IF_MACRO(GetProcessBundleLocation(&psn, &fsref) != noErr, NULL, NULL);
|
||||
cfurl = CFURLCreateFromFSRef(cfallocator, &fsref);
|
||||
@@ -236,27 +240,46 @@ char *__PHYSFS_platformCalcBaseDir(const char *argv0)
|
||||
CFRelease(cfstr);
|
||||
BAIL_IF_MACRO(cfmutstr == NULL, NULL, NULL);
|
||||
|
||||
/* Find last dirsep so we can chop the binary's filename from the path. */
|
||||
cfrange = CFStringFind(cfmutstr, CFSTR("/"), kCFCompareBackwards);
|
||||
if (cfrange.location == kCFNotFound)
|
||||
/* we have to decide if we got a binary's path, or the .app dir... */
|
||||
cstr = convertCFString(cfmutstr);
|
||||
if (cstr == NULL)
|
||||
{
|
||||
assert(0); /* shouldn't ever hit this... */
|
||||
CFRelease(cfmutstr);
|
||||
return(NULL);
|
||||
} /* if */
|
||||
|
||||
/* chop the "/exename" from the end of the path string... */
|
||||
cfrange.length = CFStringGetLength(cfmutstr) - cfrange.location;
|
||||
CFStringDelete(cfmutstr, cfrange);
|
||||
rc = stat(cstr, &statbuf);
|
||||
allocator.Free(cstr); /* done with this. */
|
||||
if (rc == -1)
|
||||
{
|
||||
CFRelease(cfmutstr);
|
||||
return(NULL); /* maybe default behaviour will work? */
|
||||
} /* if */
|
||||
|
||||
/* If we're an Application Bundle, chop everything but the base. */
|
||||
cfrange = CFStringFind(cfmutstr, CFSTR("/Contents/MacOS"),
|
||||
kCFCompareCaseInsensitive |
|
||||
kCFCompareBackwards |
|
||||
kCFCompareAnchored);
|
||||
if (S_ISREG(statbuf.st_mode))
|
||||
{
|
||||
/* Find last dirsep so we can chop the filename from the path. */
|
||||
cfrange = CFStringFind(cfmutstr, CFSTR("/"), kCFCompareBackwards);
|
||||
if (cfrange.location == kCFNotFound)
|
||||
{
|
||||
assert(0); /* shouldn't ever hit this... */
|
||||
CFRelease(cfmutstr);
|
||||
return(NULL);
|
||||
} /* if */
|
||||
|
||||
if (cfrange.location != kCFNotFound)
|
||||
CFStringDelete(cfmutstr, cfrange); /* chop that, too. */
|
||||
/* chop the "/exename" from the end of the path string... */
|
||||
cfrange.length = CFStringGetLength(cfmutstr) - cfrange.location;
|
||||
CFStringDelete(cfmutstr, cfrange);
|
||||
|
||||
/* If we're an Application Bundle, chop everything but the base. */
|
||||
cfrange = CFStringFind(cfmutstr, CFSTR("/Contents/MacOS"),
|
||||
kCFCompareCaseInsensitive |
|
||||
kCFCompareBackwards |
|
||||
kCFCompareAnchored);
|
||||
|
||||
if (cfrange.location != kCFNotFound)
|
||||
CFStringDelete(cfmutstr, cfrange); /* chop that, too. */
|
||||
} /* if */
|
||||
|
||||
retval = convertCFString(cfmutstr);
|
||||
CFRelease(cfmutstr);
|
||||
@@ -353,9 +376,9 @@ int __PHYSFS_platformSetDefaultAllocator(PHYSFS_Allocator *a)
|
||||
} /* __PHYSFS_platformSetDefaultAllocator */
|
||||
|
||||
|
||||
PHYSFS_uint64 __PHYSFS_platformGetThreadID(void)
|
||||
void *__PHYSFS_platformGetThreadID(void)
|
||||
{
|
||||
return( (PHYSFS_uint64) ((size_t) MPCurrentTaskID()) );
|
||||
return( (void *) ((size_t) MPCurrentTaskID()) );
|
||||
} /* __PHYSFS_platformGetThreadID */
|
||||
|
||||
|
||||
|
||||
@@ -649,7 +649,7 @@ PHYSFS_sint64 __PHYSFS_platformGetLastModTime(const char *fname)
|
||||
} /* __PHYSFS_platformGetLastModTime */
|
||||
|
||||
|
||||
PHYSFS_uint64 __PHYSFS_platformGetThreadID(void)
|
||||
void *__PHYSFS_platformGetThreadID(void)
|
||||
{
|
||||
PTIB ptib;
|
||||
PPIB ppib;
|
||||
@@ -659,7 +659,7 @@ PHYSFS_uint64 __PHYSFS_platformGetThreadID(void)
|
||||
* default value (zero might as well do) if it does.
|
||||
*/
|
||||
BAIL_IF_MACRO(os2err(DosGetInfoBlocks(&ptib, &ppib)) != NO_ERROR, 0, 0);
|
||||
return((PHYSFS_uint64) ptib->tib_ordinal);
|
||||
return((void *) ptib->tib_ordinal);
|
||||
} /* __PHYSFS_platformGetThreadID */
|
||||
|
||||
|
||||
|
||||
@@ -161,9 +161,9 @@ char *__PHYSFS_platformGetUserDir(void)
|
||||
} /* __PHYSFS_platformGetUserDir */
|
||||
|
||||
|
||||
PHYSFS_uint64 __PHYSFS_platformGetThreadID(void)
|
||||
void *__PHYSFS_platformGetThreadID(void)
|
||||
{
|
||||
return(1); /* single threaded. */
|
||||
return((void *)1); /* single threaded. */
|
||||
} /* __PHYSFS_platformGetThreadID */
|
||||
|
||||
|
||||
@@ -467,7 +467,7 @@ PHYSFS_sint64 __PHYSFS_platformTell(void *opaque)
|
||||
LowPos = SetFilePointer(Handle, 0, &HighPos, FILE_CURRENT);
|
||||
if ((LowPos == INVALID_SET_FILE_POINTER) && (GetLastError() != NO_ERROR))
|
||||
{
|
||||
BAIL_MACRO(win32strerror(), 0);
|
||||
BAIL_MACRO(win32strerror(), -1);
|
||||
} /* if */
|
||||
else
|
||||
{
|
||||
@@ -505,14 +505,18 @@ PHYSFS_sint64 __PHYSFS_platformFileLength(void *opaque)
|
||||
|
||||
int __PHYSFS_platformEOF(void *opaque)
|
||||
{
|
||||
const PHYSFS_sint64 FileLength = __PHYSFS_platformFileLength(opaque);
|
||||
PHYSFS_sint64 FilePosition;
|
||||
int retval = 0;
|
||||
|
||||
if (FileLength == 0)
|
||||
return 1; /* we're definitely at EOF. */
|
||||
|
||||
/* Get the current position in the file */
|
||||
if ((FilePosition = __PHYSFS_platformTell(opaque)) != 0)
|
||||
if ((FilePosition = __PHYSFS_platformTell(opaque)) != -1)
|
||||
{
|
||||
/* Non-zero if EOF is equal to the file length */
|
||||
retval = FilePosition == __PHYSFS_platformFileLength(opaque);
|
||||
retval = (FilePosition == FileLength);
|
||||
} /* if */
|
||||
|
||||
return(retval);
|
||||
|
||||
@@ -383,7 +383,7 @@ int __PHYSFS_platformEOF(void *opaque)
|
||||
{
|
||||
PHYSFS_sint64 pos = __PHYSFS_platformTell(opaque);
|
||||
PHYSFS_sint64 len = __PHYSFS_platformFileLength(opaque);
|
||||
return(pos >= len);
|
||||
return((pos < 0) || (len < 0) || (pos >= len));
|
||||
} /* __PHYSFS_platformEOF */
|
||||
|
||||
|
||||
|
||||
@@ -342,7 +342,7 @@ int __PHYSFS_platformSetDefaultAllocator(PHYSFS_Allocator *a)
|
||||
|
||||
#if (defined PHYSFS_NO_THREAD_SUPPORT)
|
||||
|
||||
PHYSFS_uint64 __PHYSFS_platformGetThreadID(void) { return(0x0001); }
|
||||
void *__PHYSFS_platformGetThreadID(void) { return((void *) 0x0001); }
|
||||
void *__PHYSFS_platformCreateMutex(void) { return((void *) 0x0001); }
|
||||
void __PHYSFS_platformDestroyMutex(void *mutex) {}
|
||||
int __PHYSFS_platformGrabMutex(void *mutex) { return(1); }
|
||||
@@ -357,24 +357,9 @@ typedef struct
|
||||
PHYSFS_uint32 count;
|
||||
} PthreadMutex;
|
||||
|
||||
/* Just in case; this is a panic value. */
|
||||
#if ((!defined SIZEOF_INT) || (SIZEOF_INT <= 0))
|
||||
# define SIZEOF_INT 4
|
||||
#endif
|
||||
|
||||
#if (SIZEOF_INT == 4)
|
||||
# define PHTREAD_TO_UI64(thr) ( (PHYSFS_uint64) ((PHYSFS_uint32) (thr)) )
|
||||
#elif (SIZEOF_INT == 2)
|
||||
# define PHTREAD_TO_UI64(thr) ( (PHYSFS_uint64) ((PHYSFS_uint16) (thr)) )
|
||||
#elif (SIZEOF_INT == 1)
|
||||
# define PHTREAD_TO_UI64(thr) ( (PHYSFS_uint64) ((PHYSFS_uint8) (thr)) )
|
||||
#else
|
||||
# define PHTREAD_TO_UI64(thr) ((PHYSFS_uint64) (thr))
|
||||
#endif
|
||||
|
||||
PHYSFS_uint64 __PHYSFS_platformGetThreadID(void)
|
||||
void *__PHYSFS_platformGetThreadID(void)
|
||||
{
|
||||
return(PHTREAD_TO_UI64(pthread_self()));
|
||||
return( (void *) ((size_t) pthread_self()) );
|
||||
} /* __PHYSFS_platformGetThreadID */
|
||||
|
||||
|
||||
|
||||
@@ -462,6 +462,7 @@ static int determineUserDir(void)
|
||||
*/
|
||||
rc = pGetUserProfileDirectoryW(accessToken, &dummy, &psize);
|
||||
assert(!rc); /* !!! FIXME: handle this gracefully. */
|
||||
(void)rc;
|
||||
|
||||
/* Allocate memory for the profile directory */
|
||||
wstr = (LPWSTR) __PHYSFS_smallAlloc(psize * sizeof (WCHAR));
|
||||
@@ -559,9 +560,9 @@ char *__PHYSFS_platformGetUserDir(void)
|
||||
} /* __PHYSFS_platformGetUserDir */
|
||||
|
||||
|
||||
PHYSFS_uint64 __PHYSFS_platformGetThreadID(void)
|
||||
void *__PHYSFS_platformGetThreadID(void)
|
||||
{
|
||||
return((PHYSFS_uint64) GetCurrentThreadId());
|
||||
return( (void *) ((size_t) GetCurrentThreadId()) );
|
||||
} /* __PHYSFS_platformGetThreadID */
|
||||
|
||||
|
||||
@@ -1142,7 +1143,7 @@ PHYSFS_sint64 __PHYSFS_platformTell(void *opaque)
|
||||
if ( (LowPos == PHYSFS_INVALID_SET_FILE_POINTER) &&
|
||||
(GetLastError() != NO_ERROR) )
|
||||
{
|
||||
BAIL_MACRO(winApiStrError(), 0);
|
||||
BAIL_MACRO(winApiStrError(), -1);
|
||||
} /* if */
|
||||
else
|
||||
{
|
||||
@@ -1181,14 +1182,18 @@ PHYSFS_sint64 __PHYSFS_platformFileLength(void *opaque)
|
||||
|
||||
int __PHYSFS_platformEOF(void *opaque)
|
||||
{
|
||||
const PHYSFS_sint64 FileLength = __PHYSFS_platformFileLength(opaque);
|
||||
PHYSFS_sint64 FilePosition;
|
||||
int retval = 0;
|
||||
|
||||
if (FileLength == 0)
|
||||
return 1; /* we're definitely at EOF. */
|
||||
|
||||
/* Get the current position in the file */
|
||||
if ((FilePosition = __PHYSFS_platformTell(opaque)) != 0)
|
||||
if ((FilePosition = __PHYSFS_platformTell(opaque)) != -1)
|
||||
{
|
||||
/* Non-zero if EOF is equal to the file length */
|
||||
retval = FilePosition == __PHYSFS_platformFileLength(opaque);
|
||||
retval = (FilePosition == FileLength);
|
||||
} /* if */
|
||||
|
||||
return(retval);
|
||||
|
||||
Reference in New Issue
Block a user