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