More win32 updates.
This commit is contained in:
parent
3deb942440
commit
7aa0c252a9
|
@ -11,8 +11,9 @@
|
|||
platform/win32.c. Other cleanups to get this compiling with
|
||||
Visual C and CygWin. Added BAIL_MACRO for times when we were doing
|
||||
BAIL_IF_MACRO(1, ...). Abstracted mkdir() in the platform drivers.
|
||||
Added GRP setting output to showcfg in the Makefile. Changed
|
||||
version to 0.1.2.
|
||||
Added GRP setting output to showcfg in the Makefile. Updated INSTALL
|
||||
with license info and Win32 build instructions.
|
||||
Changed version to 0.1.2.
|
||||
|
||||
--ryan. (icculus@clutteredmind.org)
|
||||
|
||||
|
|
23
INSTALL
23
INSTALL
|
@ -1,7 +1,20 @@
|
|||
Building is very easy.
|
||||
|
||||
|
||||
ALL PLATFORMS:
|
||||
|
||||
Please understand your rights and mine: read the text file LICENSE in the root
|
||||
of the source tree. If you can't abide by it, delete this source tree now.
|
||||
|
||||
The best documentation for the PhysicsFS API is physfs.h. It is VERY heavily
|
||||
commented, and makes an excellent, in-depth reference to all the functions.
|
||||
|
||||
|
||||
UNIX:
|
||||
|
||||
Edit "Makefile", and follow the instructions. The defaults are probably okay
|
||||
for general purposes, but give it a once over to make sure.
|
||||
for general purposes, but give it a once over to make sure. If you don't have
|
||||
zLib on your system, you'll need to disable ZIP support.
|
||||
|
||||
run "make"
|
||||
|
||||
|
@ -9,5 +22,13 @@ That's it. The library will be sitting in a new directory called "bin".
|
|||
|
||||
Run "make install" to install the library for use on your system.
|
||||
|
||||
|
||||
WIN32:
|
||||
If building with CygWin, follow the Unix instructions, above. If you're using
|
||||
Visual C, unzip VisualC.zip so that the project files end up in the same
|
||||
directory as physfs.c, and point Visual C at that project to build. If you're
|
||||
using any other compiler, send me a patch when you get it working. :)
|
||||
|
||||
--ryan. (icculus@clutteredmind.org)
|
||||
|
||||
|
||||
|
|
5
Makefile
5
Makefile
|
@ -170,8 +170,13 @@ MAINSRCS := physfs.c archivers/dir.c
|
|||
ifeq ($(strip $(use_archive_zip)),true)
|
||||
MAINSRCS += archivers/zip.c archivers/unzip.c
|
||||
CFLAGS += -DPHYSFS_SUPPORTS_ZIP
|
||||
ifeq ($(strip $(cygwin)),true)
|
||||
CFLAGS += -Izlibwin32
|
||||
LDFLAGS += zlibwin32/zlibstat.lib
|
||||
else
|
||||
LDFLAGS += -lz
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(use_archive_grp)),true)
|
||||
MAINSRCS += archivers/grp.c
|
||||
|
|
|
@ -363,7 +363,7 @@ static LinkedStringList *ZIP_enumerateFiles(DirHandle *h,
|
|||
int omitSymLinks)
|
||||
{
|
||||
ZIPinfo *zi = (ZIPinfo *) (h->opaque);
|
||||
int i;
|
||||
unsigned int i;
|
||||
int dlen;
|
||||
LinkedStringList *retval = NULL;
|
||||
LinkedStringList *l = NULL;
|
||||
|
@ -470,7 +470,7 @@ static int ZIP_exists_symcheck(DirHandle *h, const char *name, int follow)
|
|||
ZIPinfo *zi = (ZIPinfo *) (h->opaque);
|
||||
int dlen;
|
||||
char *d;
|
||||
int i;
|
||||
unsigned int i;
|
||||
ZIPentry *entry;
|
||||
|
||||
dlen = strlen(name);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Unix support routines for PhysicsFS.
|
||||
* Win32 support routines for PhysicsFS.
|
||||
*
|
||||
* Please see the file LICENSE in the source's root directory.
|
||||
*
|
||||
|
@ -12,18 +12,7 @@
|
|||
|
||||
#include <windows.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <pthread.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
#include <pwd.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/param.h>
|
||||
#include <dirent.h>
|
||||
#include <time.h>
|
||||
#include <errno.h>
|
||||
|
||||
|
||||
#define __PHYSICSFS_INTERNAL__
|
||||
#include "physfs_internal.h"
|
||||
|
@ -34,20 +23,20 @@ const char *__PHYSFS_platformDirSeparator = "\\";
|
|||
|
||||
static const char *win32strerror(void)
|
||||
{
|
||||
static char msgbuf[255];
|
||||
static TCHAR msgbuf[255];
|
||||
|
||||
FormatMessage(
|
||||
FORMAT_MESSAGE_FROM_SYSTEM |
|
||||
FORMAT_MESSAGE_IGNORE_INSERTS,
|
||||
NULL,
|
||||
GetLastError(),
|
||||
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
|
||||
&msgbuf,
|
||||
0,
|
||||
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), /* Default language */
|
||||
msgbuf,
|
||||
sizeof (msgbuf) / sizeof (TCHAR),
|
||||
NULL
|
||||
);
|
||||
|
||||
return(msgbuf);
|
||||
return((const char *) msgbuf);
|
||||
} /* win32strerror */
|
||||
|
||||
|
||||
|
@ -56,7 +45,6 @@ char **__PHYSFS_platformDetectAvailableCDs(void)
|
|||
char **retval = (char **) malloc(sizeof (char *));
|
||||
int cd_count = 1; /* We count the NULL entry. */
|
||||
char drive_str[4] = "x:\\";
|
||||
int i;
|
||||
|
||||
for (drive_str[0] = 'A'; drive_str[0] <= 'Z'; drive_str[0]++)
|
||||
{
|
||||
|
@ -81,22 +69,6 @@ char **__PHYSFS_platformDetectAvailableCDs(void)
|
|||
} /* __PHYSFS_detectAvailableCDs */
|
||||
|
||||
|
||||
static char *copyEnvironmentVariable(const char *varname)
|
||||
{
|
||||
const char *envr = getenv(varname);
|
||||
char *retval = NULL;
|
||||
|
||||
if (envr != NULL)
|
||||
{
|
||||
retval = malloc(strlen(envr) + 1);
|
||||
if (retval != NULL)
|
||||
strcpy(retval, envr);
|
||||
} /* if */
|
||||
|
||||
return(retval);
|
||||
} /* copyEnvironmentVariable */
|
||||
|
||||
|
||||
char *__PHYSFS_platformCalcBaseDir(const char *argv0)
|
||||
{
|
||||
DWORD buflen = 0;
|
||||
|
@ -106,17 +78,17 @@ char *__PHYSFS_platformCalcBaseDir(const char *argv0)
|
|||
if (strchr(argv0, '\\') != NULL) /* default behaviour can handle this. */
|
||||
return(NULL);
|
||||
|
||||
SearchPath(NULL, argv0, NULL, &buflen, NULL, NULL);
|
||||
buflen = SearchPath(NULL, argv0, NULL, buflen, NULL, NULL);
|
||||
retval = (char *) malloc(buflen);
|
||||
BAIL_IF_MACRO(!retval, ERR_OUT_OF_MEMORY, NULL);
|
||||
SearchPath(NULL, argv0, NULL, &buflen, retval, &filepart);
|
||||
SearchPath(NULL, argv0, NULL, buflen, retval, &filepart);
|
||||
return(retval);
|
||||
} /* __PHYSFS_platformCalcBaseDir */
|
||||
|
||||
|
||||
char *__PHYSFS_platformGetUserName(void)
|
||||
{
|
||||
LPDWORD bufsize = 0;
|
||||
DWORD bufsize = 0;
|
||||
LPTSTR retval = NULL;
|
||||
|
||||
if (GetUserName(NULL, &bufsize) == 0) /* This SHOULD fail. */
|
||||
|
@ -146,9 +118,24 @@ int __PHYSFS_platformGetThreadID(void)
|
|||
} /* __PHYSFS_platformGetThreadID */
|
||||
|
||||
|
||||
/* ...make this Cygwin AND Visual C friendly... */
|
||||
int __PHYSFS_platformStricmp(const char *x, const char *y)
|
||||
{
|
||||
return(stricmp(x, y));
|
||||
int ux, uy;
|
||||
|
||||
do
|
||||
{
|
||||
ux = toupper((int) *x);
|
||||
uy = toupper((int) *y);
|
||||
if (ux > uy)
|
||||
return(1);
|
||||
else if (ux < uy)
|
||||
return(-1);
|
||||
x++;
|
||||
y++;
|
||||
} while ((ux) && (uy));
|
||||
|
||||
return(0);
|
||||
} /* __PHYSFS_platformStricmp */
|
||||
|
||||
|
||||
|
@ -178,6 +165,7 @@ char *__PHYSFS_platformCvtToDependent(const char *prepend,
|
|||
((append) ? strlen(append) : 0) +
|
||||
strlen(dirName) + 1;
|
||||
char *retval = malloc(len);
|
||||
char *p;
|
||||
|
||||
BAIL_IF_MACRO(retval == NULL, ERR_OUT_OF_MEMORY, NULL);
|
||||
|
||||
|
@ -217,7 +205,7 @@ LinkedStringList *__PHYSFS_platformEnumerateFiles(const char *dirname,
|
|||
dir = FindFirstFile(dirname, &ent);
|
||||
BAIL_IF_MACRO(dir == INVALID_HANDLE_VALUE, win32strerror(), NULL);
|
||||
|
||||
for (; FineNextFile(dir, &ent) != 0; )
|
||||
for (; FindNextFile(dir, &ent) != 0; )
|
||||
{
|
||||
if (strcmp(ent.cFileName, ".") == 0)
|
||||
continue;
|
||||
|
@ -267,25 +255,26 @@ int __PHYSFS_platformFileLength(FILE *handle)
|
|||
|
||||
char *__PHYSFS_platformCurrentDir(void)
|
||||
{
|
||||
LPTSTR *retval;
|
||||
LPTSTR retval;
|
||||
DWORD buflen = 0;
|
||||
|
||||
GetCurrentDirectory(&buflen, NULL);
|
||||
buflen = GetCurrentDirectory(buflen, NULL);
|
||||
retval = (LPTSTR) malloc(buflen);
|
||||
GetCurrentDirectory(&buflen, retval);
|
||||
GetCurrentDirectory(buflen, retval);
|
||||
return((char *) retval);
|
||||
} /* __PHYSFS_platformCurrentDir */
|
||||
|
||||
|
||||
char *__PHYSFS_platformRealPath(const char *path)
|
||||
{
|
||||
/* !!! FIXME: This isn't supported on CygWin! */
|
||||
return(_fullpath(NULL, path, _MAX_PATH));
|
||||
} /* __PHYSFS_platformRealPath */
|
||||
|
||||
|
||||
int __PHYSFS_platformMkDir(const char *path)
|
||||
{
|
||||
rc = CreateDirectory(path, NULL);
|
||||
DWORD rc = CreateDirectory(path, NULL);
|
||||
BAIL_IF_MACRO(rc == 0, win32strerror(), 0);
|
||||
return(1);
|
||||
} /* __PHYSFS_platformMkDir */
|
||||
|
|
Loading…
Reference in New Issue