More win32 updates.
--- a/CHANGELOG Thu Aug 23 15:39:07 2001 +0000
+++ b/CHANGELOG Thu Aug 23 16:02:51 2001 +0000
@@ -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)
--- a/INSTALL Thu Aug 23 15:39:07 2001 +0000
+++ b/INSTALL Thu Aug 23 16:02:51 2001 +0000
@@ -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 @@
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)
+
--- a/Makefile Thu Aug 23 15:39:07 2001 +0000
+++ b/Makefile Thu Aug 23 16:02:51 2001 +0000
@@ -170,8 +170,13 @@
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
--- a/archivers/zip.c Thu Aug 23 15:39:07 2001 +0000
+++ b/archivers/zip.c Thu Aug 23 16:02:51 2001 +0000
@@ -363,7 +363,7 @@
int omitSymLinks)
{
ZIPinfo *zi = (ZIPinfo *) (h->opaque);
- int i;
+ unsigned int i;
int dlen;
LinkedStringList *retval = NULL;
LinkedStringList *l = NULL;
@@ -470,7 +470,7 @@
ZIPinfo *zi = (ZIPinfo *) (h->opaque);
int dlen;
char *d;
- int i;
+ unsigned int i;
ZIPentry *entry;
dlen = strlen(name);
--- a/platform/win32.c Thu Aug 23 15:39:07 2001 +0000
+++ b/platform/win32.c Thu Aug 23 16:02:51 2001 +0000
@@ -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 @@
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 **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 @@
} /* __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 @@
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 @@
} /* __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 @@
((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 @@
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 @@
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 */