SDL: Updated PhysFS to v2.0.3
This commit is contained in:
@@ -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