Tabs-to-spaces patch by James Turk.
This commit is contained in:
parent
db279de4d1
commit
f4309f51e8
|
@ -899,9 +899,9 @@ static int zip_has_symlink_attr(ZIPentry *entry, PHYSFS_uint32 extern_attr)
|
|||
static PHYSFS_sint64 zip_dos_time_to_physfs_time(PHYSFS_uint32 dostime)
|
||||
{
|
||||
#ifdef _WIN32_WCE
|
||||
/* We have no struct tm and no mktime right now.
|
||||
FIXME: This should probably be fixed at some point.
|
||||
*/
|
||||
/* We have no struct tm and no mktime right now.
|
||||
FIXME: This should probably be fixed at some point.
|
||||
*/
|
||||
return -1;
|
||||
#else
|
||||
PHYSFS_uint32 dosdate;
|
||||
|
|
|
@ -118,8 +118,8 @@ static int MY_GETC(MY_FILETYPE *const fp) {
|
|||
}
|
||||
return c;
|
||||
}
|
||||
static char * MY_GETS(char * const str, const int size,
|
||||
MY_FILETYPE *const fp) {
|
||||
static char * MY_GETS(char * const str, const int size,
|
||||
MY_FILETYPE *const fp) {
|
||||
int i = 0;
|
||||
int c;
|
||||
do {
|
||||
|
@ -131,9 +131,9 @@ static char * MY_GETS(char * const str, const int size,
|
|||
break;
|
||||
}
|
||||
str[i++] = c;
|
||||
} while (c != '\0' &&
|
||||
c != -1 &&
|
||||
c != '\n');
|
||||
} while (c != '\0' &&
|
||||
c != -1 &&
|
||||
c != '\n');
|
||||
str[i] = '\0';
|
||||
if (i == 0) {
|
||||
return NULL;
|
||||
|
|
44
physfs.c
44
physfs.c
|
@ -165,32 +165,32 @@ static void __PHYSFS_quick_sort(void *a, PHYSFS_uint32 lo, PHYSFS_uint32 hi,
|
|||
PHYSFS_uint32 j;
|
||||
PHYSFS_uint32 v;
|
||||
|
||||
if ((hi - lo) <= PHYSFS_QUICKSORT_THRESHOLD)
|
||||
if ((hi - lo) <= PHYSFS_QUICKSORT_THRESHOLD)
|
||||
__PHYSFS_bubble_sort(a, lo, hi, cmpfn, swapfn);
|
||||
else
|
||||
{
|
||||
i = (hi + lo) / 2;
|
||||
{
|
||||
i = (hi + lo) / 2;
|
||||
|
||||
if (cmpfn(a, lo, i) > 0) swapfn(a, lo, i);
|
||||
if (cmpfn(a, lo, hi) > 0) swapfn(a, lo, hi);
|
||||
if (cmpfn(a, i, hi) > 0) swapfn(a, i, hi);
|
||||
if (cmpfn(a, lo, hi) > 0) swapfn(a, lo, hi);
|
||||
if (cmpfn(a, i, hi) > 0) swapfn(a, i, hi);
|
||||
|
||||
j = hi - 1;
|
||||
swapfn(a, i, j);
|
||||
i = lo;
|
||||
v = j;
|
||||
while (1)
|
||||
{
|
||||
while(cmpfn(a, ++i, v) < 0) { /* do nothing */ }
|
||||
while(cmpfn(a, --j, v) > 0) { /* do nothing */ }
|
||||
if (j < i)
|
||||
j = hi - 1;
|
||||
swapfn(a, i, j);
|
||||
i = lo;
|
||||
v = j;
|
||||
while (1)
|
||||
{
|
||||
while(cmpfn(a, ++i, v) < 0) { /* do nothing */ }
|
||||
while(cmpfn(a, --j, v) > 0) { /* do nothing */ }
|
||||
if (j < i)
|
||||
break;
|
||||
swapfn(a, i, j);
|
||||
} /* while */
|
||||
swapfn(a, i, hi-1);
|
||||
__PHYSFS_quick_sort(a, lo, j, cmpfn, swapfn);
|
||||
__PHYSFS_quick_sort(a, i+1, hi, cmpfn, swapfn);
|
||||
} /* else */
|
||||
swapfn(a, i, j);
|
||||
} /* while */
|
||||
swapfn(a, i, hi-1);
|
||||
__PHYSFS_quick_sort(a, lo, j, cmpfn, swapfn);
|
||||
__PHYSFS_quick_sort(a, i+1, hi, cmpfn, swapfn);
|
||||
} /* else */
|
||||
} /* __PHYSFS_quick_sort */
|
||||
|
||||
|
||||
|
@ -675,7 +675,7 @@ static char *calculateBaseDir(const char *argv0)
|
|||
*/
|
||||
retval = __PHYSFS_platformCurrentDir();
|
||||
if(retval != NULL) {
|
||||
return(retval);
|
||||
return(retval);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1851,7 +1851,7 @@ PHYSFS_sint64 PHYSFS_fileLength(PHYSFS_file *handle)
|
|||
int PHYSFS_setBuffer(PHYSFS_file *handle, PHYSFS_uint64 _bufsize)
|
||||
{
|
||||
FileHandle *h = (FileHandle *) handle->opaque;
|
||||
PHYSFS_uint32 bufsize = (PHYSFS_uint32) _bufsize;
|
||||
PHYSFS_uint32 bufsize = (PHYSFS_uint32) _bufsize;
|
||||
|
||||
BAIL_IF_MACRO(_bufsize > 0xFFFFFFFF, "buffer must fit in 32-bits", 0);
|
||||
BAIL_IF_MACRO(!PHYSFS_flush(handle), NULL, 0);
|
||||
|
|
|
@ -54,28 +54,28 @@
|
|||
#ifndef PHYSFS_Swap16
|
||||
static __inline__ PHYSFS_uint16 PHYSFS_Swap16(PHYSFS_uint16 D)
|
||||
{
|
||||
return((D<<8)|(D>>8));
|
||||
return((D<<8)|(D>>8));
|
||||
}
|
||||
#endif
|
||||
#ifndef PHYSFS_Swap32
|
||||
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
|
||||
#ifndef PHYSFS_NO_64BIT_SUPPORT
|
||||
#ifndef PHYSFS_Swap64
|
||||
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 */
|
||||
lo = (PHYSFS_uint32)(val&0xFFFFFFFF);
|
||||
val >>= 32;
|
||||
hi = (PHYSFS_uint32)(val&0xFFFFFFFF);
|
||||
val = PHYSFS_Swap32(lo);
|
||||
val <<= 32;
|
||||
val |= PHYSFS_Swap32(hi);
|
||||
return(val);
|
||||
/* Separate into high and low 32-bit values and swap them */
|
||||
lo = (PHYSFS_uint32)(val&0xFFFFFFFF);
|
||||
val >>= 32;
|
||||
hi = (PHYSFS_uint32)(val&0xFFFFFFFF);
|
||||
val = PHYSFS_Swap32(lo);
|
||||
val <<= 32;
|
||||
val |= PHYSFS_Swap32(hi);
|
||||
return(val);
|
||||
}
|
||||
#endif
|
||||
#else
|
||||
|
@ -84,7 +84,7 @@ static __inline__ PHYSFS_uint64 PHYSFS_Swap64(PHYSFS_uint64 val) {
|
|||
If there is no real 64-bit datatype, then compilers will complain about
|
||||
the fake 64-bit datatype that PHYSFS provides when it compiles user code.
|
||||
*/
|
||||
#define PHYSFS_Swap64(X) (X)
|
||||
#define PHYSFS_Swap64(X) (X)
|
||||
#endif
|
||||
#endif /* PHYSFS_NO_64BIT_SUPPORT */
|
||||
|
||||
|
|
|
@ -622,15 +622,15 @@ typedef struct __PHYSFS_DIRFUNCTIONS__
|
|||
int (*isSymLink)(DirHandle *r, const char *name, int *fileExists);
|
||||
|
||||
/*
|
||||
* Retrieve the last modification time (mtime) of a file.
|
||||
* Returns -1 on failure, or the file's mtime in seconds since
|
||||
* the epoch (Jan 1, 1970) on success.
|
||||
* Retrieve the last modification time (mtime) of a file.
|
||||
* Returns -1 on failure, or the file's mtime in seconds since
|
||||
* the epoch (Jan 1, 1970) on success.
|
||||
* This filename is in platform-independent notation.
|
||||
*
|
||||
* Regardless of success or failure, please set *exists to
|
||||
* non-zero if the file existed (even if it's a broken symlink!),
|
||||
* zero if it did not.
|
||||
*/
|
||||
*/
|
||||
PHYSFS_sint64 (*getLastModTime)(DirHandle *r, const char *fnm, int *exist);
|
||||
|
||||
/*
|
||||
|
|
|
@ -16,8 +16,8 @@
|
|||
#define __PHYSICSFS_INTERNAL__
|
||||
#include "physfs_internal.h"
|
||||
|
||||
#define INVALID_FILE_ATTRIBUTES 0xFFFFFFFF
|
||||
#define INVALID_SET_FILE_POINTER 0xFFFFFFFF
|
||||
#define INVALID_FILE_ATTRIBUTES 0xFFFFFFFF
|
||||
#define INVALID_SET_FILE_POINTER 0xFFFFFFFF
|
||||
typedef struct
|
||||
{
|
||||
HANDLE handle;
|
||||
|
@ -41,15 +41,15 @@ static const char *win32strerror(void)
|
|||
TCHAR *ptr = msgbuf;
|
||||
|
||||
FormatMessage(
|
||||
FORMAT_MESSAGE_FROM_SYSTEM |
|
||||
FORMAT_MESSAGE_IGNORE_INSERTS,
|
||||
NULL,
|
||||
GetLastError(),
|
||||
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), /* Default language */
|
||||
msgbuf,
|
||||
sizeof (msgbuf) / sizeof (TCHAR),
|
||||
NULL
|
||||
);
|
||||
FORMAT_MESSAGE_FROM_SYSTEM |
|
||||
FORMAT_MESSAGE_IGNORE_INSERTS,
|
||||
NULL,
|
||||
GetLastError(),
|
||||
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), /* Default language */
|
||||
msgbuf,
|
||||
sizeof (msgbuf) / sizeof (TCHAR),
|
||||
NULL
|
||||
);
|
||||
|
||||
/* chop off newlines. */
|
||||
for (ptr = msgbuf; *ptr; ptr++)
|
||||
|
@ -71,23 +71,23 @@ static char *UnicodeToAsc(const wchar_t *w_str)
|
|||
|
||||
if(w_str!=NULL)
|
||||
{
|
||||
int len=wcslen(w_str)+1;
|
||||
str=(char *)malloc(len);
|
||||
int len=wcslen(w_str)+1;
|
||||
str=(char *)malloc(len);
|
||||
|
||||
if(WideCharToMultiByte(CP_ACP,0,w_str,-1,str,len,NULL,NULL)==0)
|
||||
{ //Conversion failed
|
||||
free(str);
|
||||
return NULL;
|
||||
}
|
||||
else
|
||||
{ //Conversion successful
|
||||
return(str);
|
||||
}
|
||||
if(WideCharToMultiByte(CP_ACP,0,w_str,-1,str,len,NULL,NULL)==0)
|
||||
{ //Conversion failed
|
||||
free(str);
|
||||
return NULL;
|
||||
}
|
||||
else
|
||||
{ //Conversion successful
|
||||
return(str);
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{ //Given NULL string
|
||||
return NULL;
|
||||
{ //Given NULL string
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -96,21 +96,21 @@ static wchar_t *AscToUnicode(const char *str)
|
|||
wchar_t *w_str=NULL;
|
||||
if(str!=NULL)
|
||||
{
|
||||
int len=strlen(str)+1;
|
||||
w_str=(wchar_t *)malloc(sizeof(wchar_t)*len);
|
||||
if(MultiByteToWideChar(CP_ACP,0,str,-1,w_str,len)==0)
|
||||
{
|
||||
free(w_str);
|
||||
return NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
return(w_str);
|
||||
}
|
||||
int len=strlen(str)+1;
|
||||
w_str=(wchar_t *)malloc(sizeof(wchar_t)*len);
|
||||
if(MultiByteToWideChar(CP_ACP,0,str,-1,w_str,len)==0)
|
||||
{
|
||||
free(w_str);
|
||||
return NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
return NULL;
|
||||
return(w_str);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -130,16 +130,16 @@ static char *getExePath()
|
|||
__PHYSFS_setError(win32strerror());
|
||||
} else {
|
||||
retval[buflen] = '\0'; /* does API always null-terminate this? */
|
||||
ptr = retval+buflen;
|
||||
while( ptr != retval )
|
||||
{
|
||||
if( *ptr != _T('\\') ) {
|
||||
*ptr-- = _T('\0');
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
success = 1;
|
||||
ptr = retval+buflen;
|
||||
while( ptr != retval )
|
||||
{
|
||||
if( *ptr != _T('\\') ) {
|
||||
*ptr-- = _T('\0');
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
success = 1;
|
||||
} /* else */
|
||||
|
||||
if (!success)
|
||||
|
@ -156,7 +156,7 @@ static char *getExePath()
|
|||
charretval = UnicodeToAsc(retval);
|
||||
free(retval);
|
||||
if(charretval == NULL) {
|
||||
BAIL_IF_MACRO(retval == NULL, ERR_OUT_OF_MEMORY, NULL);
|
||||
BAIL_IF_MACRO(retval == NULL, ERR_OUT_OF_MEMORY, NULL);
|
||||
}
|
||||
|
||||
return(charretval); /* w00t. */
|
||||
|
@ -220,11 +220,11 @@ int __PHYSFS_platformExists(const char *fname)
|
|||
int retval=0;
|
||||
|
||||
wchar_t *w_fname=AscToUnicode(fname);
|
||||
|
||||
|
||||
if(w_fname!=NULL)
|
||||
{
|
||||
retval=(GetFileAttributes(w_fname) != INVALID_FILE_ATTRIBUTES);
|
||||
free(w_fname);
|
||||
retval=(GetFileAttributes(w_fname) != INVALID_FILE_ATTRIBUTES);
|
||||
free(w_fname);
|
||||
}
|
||||
|
||||
return(retval);
|
||||
|
@ -245,8 +245,8 @@ int __PHYSFS_platformIsDirectory(const char *fname)
|
|||
|
||||
if(w_fname!=NULL)
|
||||
{
|
||||
retval=((GetFileAttributes(w_fname) & FILE_ATTRIBUTE_DIRECTORY) != 0);
|
||||
free(w_fname);
|
||||
retval=((GetFileAttributes(w_fname) & FILE_ATTRIBUTE_DIRECTORY) != 0);
|
||||
free(w_fname);
|
||||
}
|
||||
|
||||
return(retval);
|
||||
|
@ -258,8 +258,8 @@ char *__PHYSFS_platformCvtToDependent(const char *prepend,
|
|||
const char *append)
|
||||
{
|
||||
int len = ((prepend) ? strlen(prepend) : 0) +
|
||||
((append) ? strlen(append) : 0) +
|
||||
strlen(dirName) + 1;
|
||||
((append) ? strlen(append) : 0) +
|
||||
strlen(dirName) + 1;
|
||||
char *retval = malloc(len);
|
||||
char *p;
|
||||
|
||||
|
@ -302,7 +302,7 @@ LinkedStringList *__PHYSFS_platformEnumerateFiles(const char *dirname,
|
|||
|
||||
/* Allocate a new string for path, maybe '\\', "*", and NULL terminator */
|
||||
SearchPath = (char *) alloca(len + 3);
|
||||
BAIL_IF_MACRO(SearchPath == NULL, ERR_OUT_OF_MEMORY, NULL);
|
||||
BAIL_IF_MACRO(SearchPath == NULL, ERR_OUT_OF_MEMORY, NULL);
|
||||
|
||||
/* Copy current dirname */
|
||||
strcpy(SearchPath, dirname);
|
||||
|
@ -325,7 +325,7 @@ LinkedStringList *__PHYSFS_platformEnumerateFiles(const char *dirname,
|
|||
|
||||
if(dir == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
return NULL;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
do
|
||||
|
@ -340,7 +340,7 @@ LinkedStringList *__PHYSFS_platformEnumerateFiles(const char *dirname,
|
|||
if (l == NULL)
|
||||
break;
|
||||
|
||||
l->str=UnicodeToAsc(ent.cFileName);
|
||||
l->str=UnicodeToAsc(ent.cFileName);
|
||||
|
||||
if (l->str == NULL)
|
||||
{
|
||||
|
@ -385,17 +385,17 @@ int __PHYSFS_platformMkDir(const char *path)
|
|||
wchar_t *w_path = AscToUnicode(path);
|
||||
if(w_path!=NULL)
|
||||
{
|
||||
DWORD rc = CreateDirectory(w_path, NULL);
|
||||
free(w_path);
|
||||
if(rc==0)
|
||||
{
|
||||
return(0);
|
||||
}
|
||||
return(1);
|
||||
DWORD rc = CreateDirectory(w_path, NULL);
|
||||
free(w_path);
|
||||
if(rc==0)
|
||||
{
|
||||
return(0);
|
||||
}
|
||||
return(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
return(0);
|
||||
return(0);
|
||||
}
|
||||
} /* __PHYSFS_platformMkDir */
|
||||
|
||||
|
@ -413,7 +413,7 @@ static void *doOpen(const char *fname, DWORD mode, DWORD creation, int rdonly)
|
|||
|
||||
if(fileHandle==INVALID_HANDLE_VALUE)
|
||||
{
|
||||
return NULL;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
BAIL_IF_MACRO(fileHandle == INVALID_HANDLE_VALUE, win32strerror(), NULL);
|
||||
|
@ -421,8 +421,8 @@ static void *doOpen(const char *fname, DWORD mode, DWORD creation, int rdonly)
|
|||
retval = malloc(sizeof (winCEfile));
|
||||
if (retval == NULL)
|
||||
{
|
||||
CloseHandle(fileHandle);
|
||||
BAIL_MACRO(ERR_OUT_OF_MEMORY, NULL);
|
||||
CloseHandle(fileHandle);
|
||||
BAIL_MACRO(ERR_OUT_OF_MEMORY, NULL);
|
||||
} /* if */
|
||||
|
||||
retval->readonly = rdonly;
|
||||
|
@ -474,7 +474,7 @@ PHYSFS_sint64 __PHYSFS_platformRead(void *opaque, void *buffer,
|
|||
/*!!! - uint32 might be a greater # than DWORD */
|
||||
if(!ReadFile(FileHandle, buffer, count * size, &CountOfBytesRead, NULL))
|
||||
{
|
||||
retval=-1;
|
||||
retval=-1;
|
||||
} /* if */
|
||||
else
|
||||
{
|
||||
|
@ -499,7 +499,7 @@ PHYSFS_sint64 __PHYSFS_platformWrite(void *opaque, const void *buffer,
|
|||
/*!!! - uint32 might be a greater # than DWORD */
|
||||
if(!WriteFile(FileHandle, buffer, count * size, &CountOfBytesWritten, NULL))
|
||||
{
|
||||
retval=-1;
|
||||
retval=-1;
|
||||
} /* if */
|
||||
else
|
||||
{
|
||||
|
@ -626,14 +626,14 @@ int __PHYSFS_platformDelete(const char *path)
|
|||
/* If filename is a folder */
|
||||
if (GetFileAttributes(w_path) == FILE_ATTRIBUTE_DIRECTORY)
|
||||
{
|
||||
int retval=!RemoveDirectory(w_path);
|
||||
free(w_path);
|
||||
int retval=!RemoveDirectory(w_path);
|
||||
free(w_path);
|
||||
BAIL_IF_MACRO(retval, win32strerror(), 0);
|
||||
} /* if */
|
||||
else
|
||||
{
|
||||
int retval=!DeleteFile(w_path);
|
||||
free(w_path);
|
||||
int retval=!DeleteFile(w_path);
|
||||
free(w_path);
|
||||
BAIL_IF_MACRO(retval, win32strerror(), 0);
|
||||
} /* else */
|
||||
|
||||
|
|
Loading…
Reference in New Issue