Patches for correctness and cleaner win32 support.
This commit is contained in:
parent
7ffd15fb42
commit
748cbac1c0
12
Makefile
12
Makefile
|
@ -175,9 +175,9 @@ ifeq ($(strip $(use_archive_zip)),true)
|
|||
CFLAGS += -DPHYSFS_SUPPORTS_ZIP
|
||||
LDFLAGS += -lz
|
||||
ifeq ($(strip $(cygwin)),true)
|
||||
EXTRABUILD += zlibwin32/zlib.a
|
||||
CFLAGS += -Izlibwin32
|
||||
LDFLAGS += -Lzlibwin32
|
||||
EXTRABUILD += zlib114/zlib114.a
|
||||
CFLAGS += -Izlib114
|
||||
LDFLAGS += -Lzlib114
|
||||
endif
|
||||
endif
|
||||
|
||||
|
@ -264,8 +264,8 @@ $(BINDIR):
|
|||
|
||||
|
||||
ifeq ($(strip $(cygwin)),true)
|
||||
zlibwin32/zlib.a:
|
||||
cd zlibwin32 ; $(MAKE) CC=$(CC)
|
||||
zlib114/zlib114.a:
|
||||
cd zlib114 ; $(MAKE) CC=$(CC)
|
||||
endif
|
||||
|
||||
|
||||
|
@ -275,7 +275,7 @@ clean:
|
|||
rm -f $(CLEANUP)
|
||||
rm -rf $(BINDIR)
|
||||
ifeq ($(strip $(cygwin)),true)
|
||||
cd zlibwin32 ; $(MAKE) clean
|
||||
cd zlib114 ; $(MAKE) clean
|
||||
endif
|
||||
|
||||
listobjs:
|
||||
|
|
|
@ -133,7 +133,7 @@ static PHYSFS_sint64 GRP_read(FileHandle *handle, void *buffer,
|
|||
PHYSFS_uint64 objsLeft = (bytesLeft / objSize);
|
||||
|
||||
if (objsLeft < objCount)
|
||||
objCount = objsLeft;
|
||||
objCount = (PHYSFS_uint32) objsLeft;
|
||||
|
||||
return(__PHYSFS_platformRead(fh, buffer, objSize, objCount));
|
||||
} /* GRP_read */
|
||||
|
@ -143,7 +143,9 @@ static int GRP_eof(FileHandle *handle)
|
|||
{
|
||||
GRPfileinfo *finfo = (GRPfileinfo *) (handle->opaque);
|
||||
void *fh = finfo->handle;
|
||||
return(__PHYSFS_platformTell(fh) >= finfo->startPos + finfo->size);
|
||||
PHYSFS_sint64 pos = __PHYSFS_platformTell(fh);
|
||||
BAIL_IF_MACRO(pos < 0, NULL, 1); /* (*shrug*) */
|
||||
return(pos >= (PHYSFS_sint64) (finfo->startPos + finfo->size));
|
||||
} /* GRP_eof */
|
||||
|
||||
|
||||
|
|
|
@ -153,7 +153,7 @@ static int ZIP_seek(FileHandle *handle, PHYSFS_uint64 offset)
|
|||
PHYSFS_uint32 bufsize = 4096 * 2;
|
||||
|
||||
BAIL_IF_MACRO(unztell(fh) == offset, NULL, 1);
|
||||
BAIL_IF_MACRO(ZIP_fileLength(handle) <= offset, ERR_PAST_EOF, 0);
|
||||
BAIL_IF_MACRO(ZIP_fileLength(handle) <= (PHYSFS_sint64) offset, ERR_PAST_EOF, 0);
|
||||
|
||||
/* reset to the start of the zipfile. */
|
||||
unzCloseCurrentFile(fh);
|
||||
|
|
15
physfs.h
15
physfs.h
|
@ -129,10 +129,6 @@
|
|||
#ifndef _INCLUDE_PHYSFS_H_
|
||||
#define _INCLUDE_PHYSFS_H_
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
@ -143,8 +139,6 @@ extern "C" {
|
|||
#define __EXPORT__
|
||||
#endif
|
||||
|
||||
|
||||
/* !!! FIXME: This is not universal. */
|
||||
typedef unsigned char PHYSFS_uint8;
|
||||
typedef signed char PHYSFS_sint8;
|
||||
typedef unsigned short PHYSFS_uint16;
|
||||
|
@ -152,13 +146,12 @@ typedef signed short PHYSFS_sint16;
|
|||
typedef unsigned int PHYSFS_uint32;
|
||||
typedef signed int PHYSFS_sint32;
|
||||
|
||||
#ifdef PHYSFS_NO_64BIT_SUPPORT /* oh well. */
|
||||
#if (defined PHYSFS_NO_64BIT_SUPPORT) /* oh well. */
|
||||
typedef PHYSFS_uint32 PHYSFS_uint64;
|
||||
typedef PHYSFS_sint32 PHYSFS_sint64;
|
||||
#elif _WIN32
|
||||
/*!!! No 64-bit unsigned in Win32???? */
|
||||
typedef LONGLONG PHYSFS_sint64;
|
||||
typedef LONGLONG PHYSFS_uint64;
|
||||
#elif (defined _MSC_VER)
|
||||
typedef signed __int64 PHYSFS_sint64;
|
||||
typedef unsigned __int64 PHYSFS_uint64;
|
||||
#else
|
||||
typedef unsigned long long PHYSFS_uint64;
|
||||
typedef signed long long PHYSFS_sint64;
|
||||
|
|
|
@ -40,22 +40,26 @@
|
|||
#define PHYSFS_Swap32 __arch__swab32
|
||||
#endif
|
||||
#endif /* linux */
|
||||
|
||||
|
||||
#if (defined _MSC_VER)
|
||||
#define inline __inline
|
||||
#endif
|
||||
|
||||
#ifndef PHYSFS_Swap16
|
||||
static __inline__ PHYSFS_uint16 PHYSFS_Swap16(PHYSFS_uint16 D)
|
||||
static inline PHYSFS_uint16 PHYSFS_Swap16(PHYSFS_uint16 D)
|
||||
{
|
||||
return((D<<8)|(D>>8));
|
||||
}
|
||||
#endif
|
||||
#ifndef PHYSFS_Swap32
|
||||
static __inline__ PHYSFS_uint32 PHYSFS_Swap32(PHYSFS_uint32 D)
|
||||
static inline PHYSFS_uint32 PHYSFS_Swap32(PHYSFS_uint32 D)
|
||||
{
|
||||
return((D<<24)|((D<<8)&0x00FF0000)|((D>>8)&0x0000FF00)|(D>>24));
|
||||
}
|
||||
#endif
|
||||
#ifndef PHYSFS_NO_64BIT_SUPPORT
|
||||
#ifndef PHYSFS_Swap64
|
||||
static __inline__ PHYSFS_uint64 PHYSFS_Swap64(PHYSFS_uint64 val) {
|
||||
static inline PHYSFS_uint64 PHYSFS_Swap64(PHYSFS_uint64 val) {
|
||||
PHYSFS_uint32 hi, lo;
|
||||
|
||||
/* Separate into high and low 32-bit values and swap them */
|
||||
|
|
|
@ -184,6 +184,9 @@ PHYSFS_uint64 __PHYSFS_platformGetThreadID(void)
|
|||
/* ...make this Cygwin AND Visual C friendly... */
|
||||
int __PHYSFS_platformStricmp(const char *x, const char *y)
|
||||
{
|
||||
#if (defined _MSC_VER)
|
||||
return(stricmp(x, y));
|
||||
#else
|
||||
int ux, uy;
|
||||
|
||||
do
|
||||
|
@ -199,6 +202,7 @@ int __PHYSFS_platformStricmp(const char *x, const char *y)
|
|||
} while ((ux) && (uy));
|
||||
|
||||
return(0);
|
||||
#endif
|
||||
} /* __PHYSFS_platformStricmp */
|
||||
|
||||
|
||||
|
@ -469,9 +473,6 @@ static int doNTInit()
|
|||
/*!!! Second parameter can't be NULL or the function fails??? */
|
||||
if(!GetUserProfileDirectory(AccessTokenHandle, TempProfileDirectory, &pathsize))
|
||||
{
|
||||
const char *temp;
|
||||
temp = win32strerror();
|
||||
|
||||
/* Allocate memory for the profile directory */
|
||||
ProfileDirectory = (char *)malloc(pathsize);
|
||||
BAIL_IF_MACRO(ProfileDirectory == NULL, ERR_OUT_OF_MEMORY, 0);
|
||||
|
|
Loading…
Reference in New Issue