Compare commits
24 Commits
main
...
release-2.
Author | SHA1 | Date |
---|---|---|
Ryan C. Gordon | 3388e96bce | |
Ryan C. Gordon | f0c9799c69 | |
Ryan C. Gordon | aadfb3b33a | |
Ryan C. Gordon | b73d4a1b3c | |
Ryan C. Gordon | c710fb637a | |
Ryan C. Gordon | 0166d7302a | |
Ryan C. Gordon | 06c6e8806b | |
Ryan C. Gordon | 9e7d931a08 | |
Ryan C. Gordon | ff0b95c758 | |
Ryan C. Gordon | 3ffdc65c6e | |
Ryan C. Gordon | b45c0ce151 | |
Ryan C. Gordon | c906916f4e | |
Ryan C. Gordon | 2276520de9 | |
Ryan C. Gordon | 7aaa4dc6bf | |
Ryan C. Gordon | 0310835418 | |
Ryan C. Gordon | 57a04afef5 | |
Ryan C. Gordon | d4c4a06b5a | |
Ryan C. Gordon | a259eb4efe | |
Ryan C. Gordon | 88268ab857 | |
Ryan C. Gordon | aa478bc5df | |
Ryan C. Gordon | e4002c6950 | |
Ryan C. Gordon | 98790d824f | |
Ryan C. Gordon | d9f0a87208 | |
Ryan C. Gordon | 8978c7dddc |
|
@ -6,7 +6,7 @@
|
|||
CMAKE_MINIMUM_REQUIRED(VERSION 2.4)
|
||||
|
||||
PROJECT(PhysicsFS)
|
||||
SET(PHYSFS_VERSION 2.0.0)
|
||||
SET(PHYSFS_VERSION 2.0.1)
|
||||
|
||||
# Increment this if/when we break backwards compatibility.
|
||||
SET(PHYSFS_SOVERSION 1)
|
||||
|
@ -60,7 +60,10 @@ IF(CMAKE_COMPILER_IS_GNUCC)
|
|||
" PHYSFS_IS_GCC4)
|
||||
|
||||
IF(PHYSFS_IS_GCC4)
|
||||
ADD_DEFINITIONS(-fvisibility=hidden)
|
||||
# Not supported on several operating systems at this time.
|
||||
IF(NOT OS2 AND NOT SOLARIS AND NOT WINDOWS)
|
||||
ADD_DEFINITIONS(-fvisibility=hidden)
|
||||
ENDIF(NOT OS2 AND NOT SOLARIS AND NOT WINDOWS)
|
||||
ENDIF(PHYSFS_IS_GCC4)
|
||||
ENDIF(CMAKE_COMPILER_IS_GNUCC)
|
||||
|
||||
|
@ -159,8 +162,6 @@ IF(UNIX)
|
|||
CHECK_INCLUDE_FILE(pthread.h HAVE_PTHREAD_H)
|
||||
IF(HAVE_PTHREAD_H)
|
||||
SET(PHYSFS_HAVE_THREAD_SUPPORT TRUE)
|
||||
ELSE(HAVE_PTHREAD_H)
|
||||
ADD_DEFINITIONS(-DPHYSFS_NO_PTHREADS_SUPPORT=1)
|
||||
ENDIF(HAVE_PTHREAD_H)
|
||||
ENDIF(BEOS)
|
||||
ENDIF(UNIX)
|
||||
|
@ -184,6 +185,7 @@ ENDIF(NOT PHYSFS_HAVE_CDROM_SUPPORT)
|
|||
IF(PHYSFS_HAVE_THREAD_SUPPORT)
|
||||
ADD_DEFINITIONS(-D_REENTRANT -D_THREAD_SAFE)
|
||||
ELSE(PHYSFS_HAVE_THREAD_SUPPORT)
|
||||
ADD_DEFINITIONS(-DPHYSFS_NO_THREAD_SUPPORT=1)
|
||||
MESSAGE(WARNING " ***")
|
||||
MESSAGE(WARNING " *** There is no thread support in this build!")
|
||||
MESSAGE(WARNING " *** PhysicsFS will NOT be reentrant!")
|
||||
|
@ -244,26 +246,21 @@ ENDIF(PHYSFS_ARCHIVE_QPAK)
|
|||
# See if some archiver required zlib, and see about using system version.
|
||||
|
||||
IF(PHYSFS_NEED_ZLIB)
|
||||
CHECK_INCLUDE_FILE(zlib.h HAVE_ZLIB_H)
|
||||
IF(HAVE_ZLIB_H)
|
||||
CHECK_LIBRARY_EXISTS("z" "inflate" "" HAVE_LIBZ)
|
||||
IF(HAVE_LIBZ)
|
||||
SET(HAVE_SYSTEM_ZLIB TRUE)
|
||||
ENDIF(HAVE_LIBZ)
|
||||
ENDIF(HAVE_ZLIB_H)
|
||||
FIND_PACKAGE(ZLIB)
|
||||
|
||||
IF(HAVE_SYSTEM_ZLIB)
|
||||
IF(ZLIB_FOUND)
|
||||
OPTION(PHYSFS_INTERNAL_ZLIB "Link own zlib instead of system library" FALSE)
|
||||
ELSE(HAVE_SYSTEM_ZLIB)
|
||||
SET(PHYSFS_INTERNAL_ZLIB TRUE)
|
||||
ENDIF(HAVE_SYSTEM_ZLIB)
|
||||
ENDIF(ZLIB_FOUND)
|
||||
|
||||
IF(PHYSFS_INTERNAL_ZLIB)
|
||||
INCLUDE_DIRECTORIES(zlib123)
|
||||
ADD_DEFINITIONS(-DZ_PREFIX=1)
|
||||
SET(PHYSFS_SRCS ${PHYSFS_SRCS} ${ZLIB_SRCS})
|
||||
ELSE(PHYSFS_INTERNAL_ZLIB)
|
||||
SET(OPTIONAL_LIBRARY_LIBS ${OPTIONAL_LIBRARY_LIBS} z)
|
||||
SET(OPTIONAL_LIBRARY_LIBS ${OPTIONAL_LIBRARY_LIBS} ${ZLIB_LIBRARY})
|
||||
INCLUDE_DIRECTORIES(${ZLIB_INCLUDE_DIR})
|
||||
ENDIF(PHYSFS_INTERNAL_ZLIB)
|
||||
ENDIF(PHYSFS_NEED_ZLIB)
|
||||
|
||||
|
@ -298,18 +295,19 @@ ENDIF(PHYSFS_BUILD_SHARED AND PHYSFS_BUILD_STATIC)
|
|||
OPTION(PHYSFS_BUILD_TEST "Build stdio test program." TRUE)
|
||||
MARK_AS_ADVANCED(PHYSFS_BUILD_TEST)
|
||||
IF(PHYSFS_BUILD_TEST)
|
||||
CHECK_INCLUDE_FILE(readline/readline.h HAVE_READLINE_H)
|
||||
CHECK_INCLUDE_FILE(readline/history.h HAVE_HISTORY_H)
|
||||
IF(HAVE_READLINE_H AND HAVE_HISTORY_H)
|
||||
FIND_PATH(READLINE_H readline/readline.h)
|
||||
FIND_PATH(HISTORY_H readline/history.h)
|
||||
IF(READLINE_H AND HISTORY_H)
|
||||
SET(CMAKE_REQUIRED_LIBRARIES curses)
|
||||
CHECK_LIBRARY_EXISTS("readline" "readline" "" HAVE_LIBREADLINE)
|
||||
CHECK_LIBRARY_EXISTS("readline" "history" "" HAVE_LIBHISTORY)
|
||||
IF(HAVE_LIBREADLINE AND HAVE_LIBHISTORY)
|
||||
FIND_LIBRARY(READLINE_LIBRARY readline)
|
||||
FIND_LIBRARY(HISTORY_LIBRARY history)
|
||||
IF(READLINE_LIBRARY AND HISTORY_LIBRARY)
|
||||
SET(HAVE_SYSTEM_READLINE TRUE)
|
||||
SET(TEST_PHYSFS_LIBS ${TEST_PHYSFS_LIBS} " " readline curses)
|
||||
SET(TEST_PHYSFS_LIBS ${TEST_PHYSFS_LIBS} ${READLINE_LIBRARY} ${CURSES_LIBRARY})
|
||||
INCLUDE_DIRECTORIES(${READLINE_H} ${HISTORY_H})
|
||||
ADD_DEFINITIONS(-DPHYSFS_HAVE_READLINE=1)
|
||||
ENDIF(HAVE_LIBREADLINE AND HAVE_LIBHISTORY)
|
||||
ENDIF(HAVE_READLINE_H AND HAVE_HISTORY_H)
|
||||
ENDIF(READLINE_LIBRARY AND HISTORY_LIBRARY)
|
||||
ENDIF(READLINE_H AND HISTORY_H)
|
||||
ADD_EXECUTABLE(test_physfs test/test_physfs.c)
|
||||
TARGET_LINK_LIBRARIES(test_physfs ${PHYSFS_LIB_TARGET} ${TEST_PHYSFS_LIBS} ${OTHER_LDFLAGS})
|
||||
SET(PHYSFS_INSTALL_TARGETS ${PHYSFS_INSTALL_TARGETS} ";test_physfs")
|
||||
|
@ -347,7 +345,13 @@ ELSE(DOXYGEN_FOUND)
|
|||
ENDIF(DOXYGEN_FOUND)
|
||||
|
||||
IF(UNIX)
|
||||
ADD_CUSTOM_TARGET(dist ./extras/makedist.sh ${PHYSFS_VERSION} COMMENT "Building source tarball")
|
||||
SET(PHYSFS_TARBALL "${CMAKE_CURRENT_SOURCE_DIR}/../physfs-${PHYSFS_VERSION}.tar.gz")
|
||||
ADD_CUSTOM_TARGET(
|
||||
dist
|
||||
hg archive -t tgz "${PHYSFS_TARBALL}"
|
||||
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
|
||||
COMMENT "Building source tarball '${PHYSFS_TARBALL}'..."
|
||||
)
|
||||
ENDIF(UNIX)
|
||||
|
||||
MACRO(MESSAGE_BOOL_OPTION _NAME _VALUE)
|
||||
|
|
|
@ -90,6 +90,12 @@ Bug fixes:
|
|||
Bug fixes:
|
||||
Olivier Boudeville
|
||||
|
||||
Bug fixes:
|
||||
Henk Boom
|
||||
|
||||
Build system fixes:
|
||||
Marc Kleine-Budde
|
||||
|
||||
Windows .rc file,
|
||||
7zip/lzma archiver:
|
||||
Dennis Schridde
|
||||
|
@ -97,6 +103,9 @@ Windows .rc file,
|
|||
OS/2 updates:
|
||||
Dave Yeo
|
||||
|
||||
Bug fixes:
|
||||
Patrice Mandin
|
||||
|
||||
Other stuff:
|
||||
Your name here! Patches go to icculus@icculus.org ...
|
||||
|
||||
|
|
2
Doxyfile
2
Doxyfile
|
@ -23,7 +23,7 @@ PROJECT_NAME = physfs
|
|||
# This could be handy for archiving the generated documentation or
|
||||
# if some version control system is used.
|
||||
|
||||
PROJECT_NUMBER = 2.0.0
|
||||
PROJECT_NUMBER = 2.0.1
|
||||
|
||||
# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute)
|
||||
# base path where the generated documentation will be put.
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
|
||||
Copyright (c) 2003-2009 Ryan C. Gordon and others.
|
||||
Copyright (c) 2003-2010 Ryan C. Gordon and others.
|
||||
|
||||
This software is provided 'as-is', without any express or implied warranty.
|
||||
In no event will the authors be held liable for any damages arising from
|
||||
|
|
|
@ -108,7 +108,7 @@ static void SzFreePhysicsFS(void *address)
|
|||
SZ_RESULT SzFileReadImp(void *object, void **buffer, size_t maxReqSize,
|
||||
size_t *processedSize)
|
||||
{
|
||||
FileInputStream *s = (FileInputStream *)(object - offsetof(FileInputStream, inStream)); // HACK!
|
||||
FileInputStream *s = (FileInputStream *)(object - offsetof(FileInputStream, inStream)); /* HACK! */
|
||||
PHYSFS_sint64 processedSizeLoc = 0;
|
||||
|
||||
if (maxReqSize > BUFFER_SIZE)
|
||||
|
@ -130,7 +130,7 @@ SZ_RESULT SzFileReadImp(void *object, void **buffer, size_t maxReqSize,
|
|||
SZ_RESULT SzFileReadImp(void *object, void *buffer, size_t size,
|
||||
size_t *processedSize)
|
||||
{
|
||||
FileInputStream *s = (FileInputStream *)((unsigned long)object - offsetof(FileInputStream, inStream)); // HACK!
|
||||
FileInputStream *s = (FileInputStream *)((unsigned long)object - offsetof(FileInputStream, inStream)); /* HACK! */
|
||||
size_t processedSizeLoc = __PHYSFS_platformRead(s->file, buffer, 1, size);
|
||||
if (processedSize != 0)
|
||||
*processedSize = processedSizeLoc;
|
||||
|
@ -145,7 +145,7 @@ SZ_RESULT SzFileReadImp(void *object, void *buffer, size_t size,
|
|||
*/
|
||||
SZ_RESULT SzFileSeekImp(void *object, CFileSize pos)
|
||||
{
|
||||
FileInputStream *s = (FileInputStream *)((unsigned long)object - offsetof(FileInputStream, inStream)); // HACK!
|
||||
FileInputStream *s = (FileInputStream *)((unsigned long)object - offsetof(FileInputStream, inStream)); /* HACK! */
|
||||
if (__PHYSFS_platformSeek(s->file, (PHYSFS_uint64) pos))
|
||||
return SZ_OK;
|
||||
return SZE_FAIL;
|
||||
|
@ -209,7 +209,7 @@ static void lzma_file_swap(void *_a, PHYSFS_uint32 one, PHYSFS_uint32 two)
|
|||
*/
|
||||
static LZMAfile * lzma_find_file(LZMAarchive *archive, const char *name)
|
||||
{
|
||||
LZMAfile *file = bsearch(name, archive->files, archive->db.Database.NumFiles, sizeof(*archive->files), lzma_file_cmp_stdlib); // FIXME: Should become __PHYSFS_search!!!
|
||||
LZMAfile *file = bsearch(name, archive->files, archive->db.Database.NumFiles, sizeof(*archive->files), lzma_file_cmp_stdlib); /* FIXME: Should become __PHYSFS_search!!! */
|
||||
|
||||
BAIL_IF_MACRO(file == NULL, ERR_NO_SUCH_FILE, NULL);
|
||||
|
||||
|
@ -225,10 +225,10 @@ static int lzma_file_init(LZMAarchive *archive, PHYSFS_uint32 fileIndex)
|
|||
LZMAfile *file = &archive->files[fileIndex];
|
||||
PHYSFS_uint32 folderIndex = archive->db.FileIndexToFolderIndexMap[fileIndex];
|
||||
|
||||
file->index = fileIndex; // Store index into 7z array, since we sort our own.
|
||||
file->index = fileIndex; /* Store index into 7z array, since we sort our own. */
|
||||
file->archive = archive;
|
||||
file->folder = (folderIndex != (PHYSFS_uint32)-1 ? &archive->folders[folderIndex] : NULL); // Directories don't have a folder (they contain no own data...)
|
||||
file->item = &archive->db.Database.Files[fileIndex]; // Holds crucial data and is often referenced -> Store link
|
||||
file->folder = (folderIndex != (PHYSFS_uint32)-1 ? &archive->folders[folderIndex] : NULL); /* Directories don't have a folder (they contain no own data...) */
|
||||
file->item = &archive->db.Database.Files[fileIndex]; /* Holds crucial data and is often referenced -> Store link */
|
||||
file->position = 0;
|
||||
file->offset = 0; /* Offset will be set by LZMA_read() */
|
||||
|
||||
|
@ -247,7 +247,7 @@ static int lzma_files_init(LZMAarchive *archive)
|
|||
{
|
||||
if (!lzma_file_init(archive, fileIndex))
|
||||
{
|
||||
return(0); // FALSE on failure
|
||||
return(0); /* FALSE on failure */
|
||||
}
|
||||
} /* for */
|
||||
|
||||
|
@ -450,7 +450,7 @@ static int LZMA_isArchive(const char *filename, int forWriting)
|
|||
/* Read signature bytes */
|
||||
if (__PHYSFS_platformRead(in, sig, k7zSignatureSize, 1) != 1)
|
||||
{
|
||||
__PHYSFS_platformClose(in); // Don't forget to close the file before returning...
|
||||
__PHYSFS_platformClose(in); /* Don't forget to close the file before returning... */
|
||||
BAIL_MACRO(NULL, 0);
|
||||
}
|
||||
|
||||
|
@ -478,7 +478,7 @@ static void *LZMA_openArchive(const char *name, int forWriting)
|
|||
{
|
||||
__PHYSFS_platformClose(archive->stream.file);
|
||||
lzma_archive_exit(archive);
|
||||
return(NULL); // Error is set by platformOpenRead!
|
||||
return(NULL); /* Error is set by platformOpenRead! */
|
||||
}
|
||||
|
||||
CrcGenerateTable();
|
||||
|
@ -491,7 +491,7 @@ static void *LZMA_openArchive(const char *name, int forWriting)
|
|||
SzArDbExFree(&archive->db, SzFreePhysicsFS);
|
||||
__PHYSFS_platformClose(archive->stream.file);
|
||||
lzma_archive_exit(archive);
|
||||
return NULL; // Error is set by lzma_err!
|
||||
return NULL; /* Error is set by lzma_err! */
|
||||
} /* if */
|
||||
|
||||
len = archive->db.Database.NumFiles * sizeof (LZMAfile);
|
||||
|
@ -568,7 +568,7 @@ static void LZMA_enumerateFiles(dvoid *opaque, const char *dname,
|
|||
if (dlen)
|
||||
{
|
||||
file = lzma_find_file(archive, dname);
|
||||
if (file != NULL) // if 'file' is NULL it should stay so, otherwise errors will not be handled
|
||||
if (file != NULL) /* if 'file' is NULL it should stay so, otherwise errors will not be handled */
|
||||
file += 1;
|
||||
}
|
||||
else
|
||||
|
@ -617,7 +617,7 @@ static PHYSFS_sint64 LZMA_getLastModTime(dvoid *opaque,
|
|||
*fileExists = (file != NULL);
|
||||
|
||||
BAIL_IF_MACRO(file == NULL, NULL, -1);
|
||||
BAIL_IF_MACRO(!file->item->IsLastWriteTimeDefined, NULL, -1); // write-time may not be defined for every file
|
||||
BAIL_IF_MACRO(!file->item->IsLastWriteTimeDefined, NULL, -1); /* write-time may not be defined for every file */
|
||||
|
||||
return(lzma_filetime_to_unix_timestamp(&file->item->LastWriteTime));
|
||||
} /* LZMA_getLastModTime */
|
||||
|
@ -649,7 +649,8 @@ static fvoid *LZMA_openRead(dvoid *opaque, const char *name, int *fileExists)
|
|||
BAIL_IF_MACRO(file == NULL, ERR_NO_SUCH_FILE, NULL);
|
||||
BAIL_IF_MACRO(file->folder == NULL, ERR_NOT_A_FILE, NULL);
|
||||
|
||||
file->folder->references++; // Increase refcount for automatic cleanup...
|
||||
file->position = 0;
|
||||
file->folder->references++; /* Increase refcount for automatic cleanup... */
|
||||
|
||||
return(file);
|
||||
} /* LZMA_openRead */
|
||||
|
|
|
@ -1,54 +0,0 @@
|
|||
#!/bin/sh
|
||||
|
||||
# This shell script is roughly equivalent to what "make dist" did in the
|
||||
# autotools build system and is called from a custom CMake target.
|
||||
|
||||
# !!! FIXME: This code sort of sucks. Consider using CPack instead...
|
||||
|
||||
if [ ! -f ./CMakeLists.txt ]; then
|
||||
echo "you are in the wrong place."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -z "$1" ]; then
|
||||
echo "Wrong arguments."
|
||||
exit 2
|
||||
fi
|
||||
|
||||
set -e
|
||||
|
||||
VERSION="$1"
|
||||
BASENAME="physfs-$VERSION"
|
||||
TARBALL="$BASENAME.tar.gz"
|
||||
TMPCPDIR="../9sdkujy75jv932-physfstmp-$VERSION"
|
||||
CPDIR="$TMPCPDIR/$BASENAME"
|
||||
|
||||
echo "Packing PhysicsFS $VERSION source tarball..."
|
||||
echo " + Setting up scratch dir..."
|
||||
rm -rf $TMPCPDIR
|
||||
mkdir $TMPCPDIR
|
||||
mkdir $CPDIR
|
||||
|
||||
echo " + Making copy of source tree in scratch dir..."
|
||||
cp -R . $CPDIR/
|
||||
echo " + Deleting cruft..."
|
||||
pushd $CPDIR >/dev/null
|
||||
rm -rf `svn propget svn:ignore .`
|
||||
rm -rf `svn status |grep '?' |sed -s 's/\?//'`
|
||||
popd >/dev/null
|
||||
rm -rf `find $CPDIR -type d -name '.svn'`
|
||||
echo " + Deleting Subversion metadata..."
|
||||
rm -rf `find $CPDIR -type d -name '.svn'`
|
||||
echo " + Fixing up permissions..."
|
||||
chmod -R a+rw $CPDIR
|
||||
chmod a+x `find $CPDIR -type d`
|
||||
echo " + Building final tarball..."
|
||||
rm -f $TARBALL
|
||||
tar -czf $TARBALL -C $TMPCPDIR $BASENAME
|
||||
echo " + Cleaning up..."
|
||||
rm -rf $TMPCPDIR
|
||||
echo " + All done! Packed to '$TARBALL' ..."
|
||||
set +e
|
||||
|
||||
exit 0
|
||||
|
|
@ -156,14 +156,14 @@ static void serve_http_request(int sock, struct sockaddr *addr,
|
|||
{
|
||||
printf("out of memory.\n");
|
||||
return;
|
||||
} // if
|
||||
} /* if */
|
||||
args->addr = (struct sockaddr *) malloc(addrlen);
|
||||
if (args->addr == NULL)
|
||||
{
|
||||
free(args);
|
||||
printf("out of memory.\n");
|
||||
return;
|
||||
} // if
|
||||
} /* if */
|
||||
|
||||
args->sock = sock;
|
||||
args->addrlen = addrlen;
|
||||
|
|
|
@ -2,6 +2,10 @@
|
|||
|
||||
#include <memory.h>
|
||||
|
||||
/* BEGIN PHYSFS CHANGE */
|
||||
#include <string.h>
|
||||
/* END PHYSFS CHANGE */
|
||||
|
||||
#include "7zDecode.h"
|
||||
#ifdef _SZ_ONE_DIRECTORY
|
||||
#include "LzmaDecode.h"
|
||||
|
|
24
physfs.c
24
physfs.c
|
@ -605,18 +605,21 @@ static int freeDirHandle(DirHandle *dh, FileHandle *openList)
|
|||
|
||||
static char *calculateUserDir(void)
|
||||
{
|
||||
char *retval = NULL;
|
||||
const char *str = NULL;
|
||||
char *retval = __PHYSFS_platformGetUserDir();
|
||||
if (retval != NULL)
|
||||
{
|
||||
/* make sure it really exists and is normalized. */
|
||||
char *ptr = __PHYSFS_platformRealPath(retval);
|
||||
allocator.Free(retval);
|
||||
retval = ptr;
|
||||
} /* if */
|
||||
|
||||
str = __PHYSFS_platformGetUserDir();
|
||||
if (str != NULL)
|
||||
retval = (char *) str;
|
||||
else
|
||||
if (retval == NULL)
|
||||
{
|
||||
const char *dirsep = PHYSFS_getDirSeparator();
|
||||
const char *uname = __PHYSFS_platformGetUserName();
|
||||
const char *str = (uname != NULL) ? uname : "default";
|
||||
|
||||
str = (uname != NULL) ? uname : "default";
|
||||
retval = (char *) allocator.Malloc(strlen(baseDir) + strlen(str) +
|
||||
strlen(dirsep) + 6);
|
||||
|
||||
|
@ -754,13 +757,6 @@ int PHYSFS_init(const char *argv0)
|
|||
BAIL_IF_MACRO(!appendDirSep(&baseDir), NULL, 0);
|
||||
|
||||
userDir = calculateUserDir();
|
||||
if (userDir != NULL)
|
||||
{
|
||||
ptr = __PHYSFS_platformRealPath(userDir);
|
||||
allocator.Free(userDir);
|
||||
userDir = ptr;
|
||||
} /* if */
|
||||
|
||||
if ((userDir == NULL) || (!appendDirSep(&userDir)))
|
||||
{
|
||||
allocator.Free(baseDir);
|
||||
|
|
10
physfs.h
10
physfs.h
|
@ -1,4 +1,8 @@
|
|||
/** \file physfs.h */
|
||||
/**
|
||||
* \file physfs.h
|
||||
*
|
||||
* Main header file for PhysicsFS.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \mainpage PhysicsFS
|
||||
|
@ -401,7 +405,7 @@ typedef struct PHYSFS_Version
|
|||
#ifndef DOXYGEN_SHOULD_IGNORE_THIS
|
||||
#define PHYSFS_VER_MAJOR 2
|
||||
#define PHYSFS_VER_MINOR 0
|
||||
#define PHYSFS_VER_PATCH 0
|
||||
#define PHYSFS_VER_PATCH 1
|
||||
#endif /* DOXYGEN_SHOULD_IGNORE_THIS */
|
||||
|
||||
|
||||
|
@ -986,7 +990,7 @@ __EXPORT__ const char *PHYSFS_getRealDir(const char *filename);
|
|||
* PHYSFS_freeList(rc);
|
||||
* \endcode
|
||||
*
|
||||
* ...will print:
|
||||
* \...will print:
|
||||
*
|
||||
* \verbatim
|
||||
* We've got [x.sav].
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
#elif ((defined __MACH__) && (defined __APPLE__))
|
||||
/* To check if iphone or not, we need to include this file */
|
||||
# include <TargetConditionals.h>
|
||||
# if (defined(TARGET_IPHONE_SIMULATOR) || (defined TARGET_OS_IPHONE))
|
||||
# if ((TARGET_IPHONE_SIMULATOR) || (TARGET_OS_IPHONE))
|
||||
# define PHYSFS_PLATFORM_UNIX
|
||||
# define PHYSFS_PLATFORM_POSIX
|
||||
# define PHYSFS_NO_CDROM_SUPPORT
|
||||
|
|
|
@ -308,7 +308,7 @@ static void utf8fromcodepoint(PHYSFS_uint32 cp, char **_dst, PHYSFS_uint64 *_len
|
|||
len--; \
|
||||
while (len) \
|
||||
{ \
|
||||
const PHYSFS_uint32 cp = (PHYSFS_uint32) *(src++); \
|
||||
const PHYSFS_uint32 cp = (PHYSFS_uint32) ((typ) (*(src++))); \
|
||||
if (cp == 0) break; \
|
||||
utf8fromcodepoint(cp, &dst, &len); \
|
||||
} \
|
||||
|
|
|
@ -604,13 +604,13 @@ int __PHYSFS_platformEOF(void *opaque)
|
|||
|
||||
int __PHYSFS_platformFlush(void *opaque)
|
||||
{
|
||||
return(os2err(DosResetBuffer((HFILE) opaque) == NO_ERROR));
|
||||
return(os2err(DosResetBuffer((HFILE) opaque)) == NO_ERROR);
|
||||
} /* __PHYSFS_platformFlush */
|
||||
|
||||
|
||||
int __PHYSFS_platformClose(void *opaque)
|
||||
{
|
||||
return(os2err(DosClose((HFILE) opaque) == NO_ERROR));
|
||||
return(os2err(DosClose((HFILE) opaque)) == NO_ERROR);
|
||||
} /* __PHYSFS_platformClose */
|
||||
|
||||
|
||||
|
@ -619,7 +619,7 @@ int __PHYSFS_platformDelete(const char *path)
|
|||
if (__PHYSFS_platformIsDirectory(path))
|
||||
return(os2err(DosDeleteDir(path)) == NO_ERROR);
|
||||
|
||||
return(os2err(DosDelete(path) == NO_ERROR));
|
||||
return(os2err(DosDelete(path)) == NO_ERROR);
|
||||
} /* __PHYSFS_platformDelete */
|
||||
|
||||
|
||||
|
|
|
@ -331,8 +331,8 @@ static void *doOpen(const char *fname, DWORD mode, DWORD creation, int rdonly)
|
|||
wchar_t *w_fname = NULL;
|
||||
|
||||
UTF8_TO_UNICODE_STACK_MACRO(w_fname, fname);
|
||||
fileHandle = CreateFile(w_fname, mode, FILE_SHARE_READ, NULL,
|
||||
creation, FILE_ATTRIBUTE_NORMAL, NULL);
|
||||
fileHandle = CreateFile(w_fname, mode, FILE_SHARE_READ | FILE_SHARE_WRITE,
|
||||
NULL, creation, FILE_ATTRIBUTE_NORMAL, NULL);
|
||||
__PHYSFS_smallFree(w_fname);
|
||||
|
||||
BAIL_IF_MACRO(fileHandle == INVALID_HANDLE_VALUE, win32strerror(), NULL);
|
||||
|
|
|
@ -97,8 +97,21 @@ char *__PHYSFS_platformGetUserName(void)
|
|||
char *__PHYSFS_platformGetUserDir(void)
|
||||
{
|
||||
char *retval = __PHYSFS_platformCopyEnvironmentVariable("HOME");
|
||||
|
||||
/* if the environment variable was set, make sure it's really a dir. */
|
||||
if (retval != NULL)
|
||||
{
|
||||
struct stat statbuf;
|
||||
if ((stat(retval, &statbuf) == -1) || (S_ISDIR(statbuf.st_mode) == 0))
|
||||
{
|
||||
allocator.Free(retval);
|
||||
retval = NULL;
|
||||
} /* if */
|
||||
} /* if */
|
||||
|
||||
if (retval == NULL)
|
||||
retval = getUserDirByUID();
|
||||
|
||||
return(retval);
|
||||
} /* __PHYSFS_platformGetUserDir */
|
||||
|
||||
|
|
|
@ -23,9 +23,8 @@
|
|||
#include <dirent.h>
|
||||
#include <time.h>
|
||||
#include <errno.h>
|
||||
#include <sys/mount.h>
|
||||
|
||||
#if (!defined PHYSFS_NO_PTHREADS_SUPPORT)
|
||||
#if (!defined PHYSFS_NO_THREAD_SUPPORT)
|
||||
#include <pthread.h>
|
||||
#endif
|
||||
|
||||
|
@ -34,6 +33,7 @@
|
|||
# undef PHYSFS_HAVE_MNTENT_H /* don't do both... */
|
||||
# endif
|
||||
# include <sys/ucred.h>
|
||||
# include <sys/mount.h>
|
||||
#endif
|
||||
|
||||
#ifdef PHYSFS_HAVE_MNTENT_H
|
||||
|
@ -42,6 +42,9 @@
|
|||
|
||||
#include "physfs_internal.h"
|
||||
|
||||
#ifndef MAXPATHLEN
|
||||
#define MAXPATHLEN 1024
|
||||
#endif
|
||||
|
||||
int __PHYSFS_platformInit(void)
|
||||
{
|
||||
|
@ -101,6 +104,14 @@ void __PHYSFS_platformDetectAvailableCDs(PHYSFS_StringCallback cb, void *data)
|
|||
int add_it = 0;
|
||||
if (strcmp(ent->mnt_type, "iso9660") == 0)
|
||||
add_it = 1;
|
||||
else if (strcmp(ent->mnt_type, "udf") == 0)
|
||||
add_it = 1;
|
||||
|
||||
/* !!! FIXME: these might pick up floppy drives, right? */
|
||||
else if (strcmp(ent->mnt_type, "auto") == 0)
|
||||
add_it = 1;
|
||||
else if (strcmp(ent->mnt_type, "supermount") == 0)
|
||||
add_it = 1;
|
||||
|
||||
/* add other mount types here */
|
||||
|
||||
|
@ -182,12 +193,42 @@ static char *findBinaryInPath(const char *bin, char *envr)
|
|||
} /* findBinaryInPath */
|
||||
|
||||
|
||||
static char *readSymLink(const char *path)
|
||||
{
|
||||
ssize_t len = 64;
|
||||
ssize_t rc = -1;
|
||||
char *retval = NULL;
|
||||
|
||||
while (1)
|
||||
{
|
||||
char *ptr = (char *) allocator.Realloc(retval, (size_t) len);
|
||||
if (ptr == NULL)
|
||||
break; /* out of memory. */
|
||||
retval = ptr;
|
||||
|
||||
rc = readlink(path, retval, len);
|
||||
if (rc == -1)
|
||||
break; /* not a symlink, i/o error, etc. */
|
||||
|
||||
else if (rc < len)
|
||||
{
|
||||
retval[rc] = '\0'; /* readlink doesn't null-terminate. */
|
||||
return retval; /* we're good to go. */
|
||||
} /* else if */
|
||||
|
||||
len *= 2; /* grow buffer, try again. */
|
||||
} /* while */
|
||||
|
||||
if (retval != NULL)
|
||||
allocator.Free(retval);
|
||||
return NULL;
|
||||
} /* readSymLink */
|
||||
|
||||
|
||||
char *__PHYSFS_platformCalcBaseDir(const char *argv0)
|
||||
{
|
||||
const char *PROC_SELF_EXE = "/proc/self/exe";
|
||||
char *retval = NULL;
|
||||
char *envr = NULL;
|
||||
struct stat stbuf;
|
||||
|
||||
/* fast path: default behaviour can handle this. */
|
||||
if ( (argv0 != NULL) && (strchr(argv0, '/') != NULL) )
|
||||
|
@ -198,20 +239,22 @@ char *__PHYSFS_platformCalcBaseDir(const char *argv0)
|
|||
* /proc filesystem, you can get the full path to the current process from
|
||||
* the /proc/self/exe symlink.
|
||||
*/
|
||||
if ((lstat(PROC_SELF_EXE, &stbuf) != -1) && (S_ISLNK(stbuf.st_mode)))
|
||||
retval = readSymLink("/proc/self/exe");
|
||||
if (retval == NULL)
|
||||
{
|
||||
const size_t len = stbuf.st_size;
|
||||
char *buf = (char *) allocator.Malloc(len+1);
|
||||
if (buf != NULL) /* if NULL, maybe you'll get lucky later. */
|
||||
{
|
||||
if (readlink(PROC_SELF_EXE, buf, len) != len)
|
||||
allocator.Free(buf);
|
||||
else
|
||||
{
|
||||
buf[len] = '\0'; /* readlink doesn't null-terminate. */
|
||||
retval = buf; /* we're good to go. */
|
||||
} /* else */
|
||||
} /* if */
|
||||
/* older kernels don't have /proc/self ... try PID version... */
|
||||
const unsigned long long pid = (unsigned long long) getpid();
|
||||
char path[64];
|
||||
const int rc = (int) snprintf(path,sizeof(path),"/proc/%llu/exe",pid);
|
||||
if ( (rc > 0) && (rc < sizeof(path)) )
|
||||
retval = readSymLink(path);
|
||||
} /* if */
|
||||
|
||||
if (retval != NULL) /* chop off filename. */
|
||||
{
|
||||
char *ptr = strrchr(retval, '/');
|
||||
if (ptr != NULL)
|
||||
*ptr = '\0';
|
||||
} /* if */
|
||||
|
||||
if ((retval == NULL) && (argv0 != NULL))
|
||||
|
@ -223,6 +266,14 @@ char *__PHYSFS_platformCalcBaseDir(const char *argv0)
|
|||
allocator.Free(envr);
|
||||
} /* if */
|
||||
|
||||
if (retval != NULL)
|
||||
{
|
||||
/* try to shrink buffer... */
|
||||
char *ptr = (char *) allocator.Realloc(retval, strlen(retval) + 1);
|
||||
if (ptr != NULL)
|
||||
retval = ptr; /* oh well if it failed. */
|
||||
} /* if */
|
||||
|
||||
return(retval);
|
||||
} /* __PHYSFS_platformCalcBaseDir */
|
||||
|
||||
|
@ -289,7 +340,7 @@ int __PHYSFS_platformSetDefaultAllocator(PHYSFS_Allocator *a)
|
|||
} /* __PHYSFS_platformSetDefaultAllocator */
|
||||
|
||||
|
||||
#if (defined PHYSFS_NO_PTHREADS_SUPPORT)
|
||||
#if (defined PHYSFS_NO_THREAD_SUPPORT)
|
||||
|
||||
PHYSFS_uint64 __PHYSFS_platformGetThreadID(void) { return(0x0001); }
|
||||
void *__PHYSFS_platformCreateMutex(void) { return((void *) 0x0001); }
|
||||
|
@ -387,7 +438,7 @@ void __PHYSFS_platformReleaseMutex(void *mutex)
|
|||
} /* if */
|
||||
} /* __PHYSFS_platformReleaseMutex */
|
||||
|
||||
#endif /* !PHYSFS_NO_PTHREADS_SUPPORT */
|
||||
#endif /* !PHYSFS_NO_THREAD_SUPPORT */
|
||||
|
||||
#endif /* PHYSFS_PLATFORM_UNIX */
|
||||
|
||||
|
|
|
@ -989,8 +989,8 @@ static void *doOpen(const char *fname, DWORD mode, DWORD creation, int rdonly)
|
|||
|
||||
UTF8_TO_UNICODE_STACK_MACRO(wfname, fname);
|
||||
BAIL_IF_MACRO(wfname == NULL, ERR_OUT_OF_MEMORY, NULL);
|
||||
fileHandle = pCreateFileW(wfname, mode, FILE_SHARE_READ, NULL,
|
||||
creation, FILE_ATTRIBUTE_NORMAL, NULL);
|
||||
fileHandle = pCreateFileW(wfname, mode, FILE_SHARE_READ | FILE_SHARE_WRITE,
|
||||
NULL, creation, FILE_ATTRIBUTE_NORMAL, NULL);
|
||||
__PHYSFS_smallFree(wfname);
|
||||
|
||||
BAIL_IF_MACRO
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
|
||||
#define TEST_VERSION_MAJOR 2
|
||||
#define TEST_VERSION_MINOR 0
|
||||
#define TEST_VERSION_PATCH 0
|
||||
#define TEST_VERSION_PATCH 1
|
||||
|
||||
static FILE *history_file = NULL;
|
||||
static PHYSFS_uint32 do_buffer_size = 0;
|
||||
|
@ -1116,7 +1116,9 @@ static void open_history_file(void)
|
|||
|
||||
do
|
||||
{
|
||||
fgets(buf, sizeof (buf), f);
|
||||
if (fgets(buf, sizeof (buf), f) == NULL)
|
||||
break;
|
||||
|
||||
if (buf[strlen(buf) - 1] == '\n')
|
||||
buf[strlen(buf) - 1] = '\0';
|
||||
add_history(buf);
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
|
||||
#define TEST_VER_MAJOR 2
|
||||
#define TEST_VER_MINOR 0
|
||||
#define TEST_VER_PATCH 0
|
||||
#define TEST_VER_PATCH 1
|
||||
|
||||
//static PHYSFS_uint32 do_buffer_size = 0;
|
||||
|
||||
|
|
Loading…
Reference in New Issue