Compare commits
35 Commits
main
...
release-2.
Author | SHA1 | Date |
---|---|---|
Ryan C. Gordon | 9b561b4799 | |
Ryan C. Gordon | 896b455f6b | |
Ryan C. Gordon | 6b96ff2524 | |
Ryan C. Gordon | b9c25d3d92 | |
Ryan C. Gordon | 57f48cb2e3 | |
Ryan C. Gordon | f6ec56cf59 | |
Ryan C. Gordon | 1c8bdd8fb4 | |
Ryan C. Gordon | 4189377d15 | |
Ryan C. Gordon | 4d961a9128 | |
Ryan C. Gordon | d6fbaedb21 | |
Ryan C. Gordon | 70cf36b6b5 | |
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)
|
CMAKE_MINIMUM_REQUIRED(VERSION 2.4)
|
||||||
|
|
||||||
PROJECT(PhysicsFS)
|
PROJECT(PhysicsFS)
|
||||||
SET(PHYSFS_VERSION 2.0.0)
|
SET(PHYSFS_VERSION 2.0.2)
|
||||||
|
|
||||||
# Increment this if/when we break backwards compatibility.
|
# Increment this if/when we break backwards compatibility.
|
||||||
SET(PHYSFS_SOVERSION 1)
|
SET(PHYSFS_SOVERSION 1)
|
||||||
|
@ -60,7 +60,10 @@ IF(CMAKE_COMPILER_IS_GNUCC)
|
||||||
" PHYSFS_IS_GCC4)
|
" PHYSFS_IS_GCC4)
|
||||||
|
|
||||||
IF(PHYSFS_IS_GCC4)
|
IF(PHYSFS_IS_GCC4)
|
||||||
|
# Not supported on several operating systems at this time.
|
||||||
|
IF(NOT OS2 AND NOT SOLARIS AND NOT WINDOWS)
|
||||||
ADD_DEFINITIONS(-fvisibility=hidden)
|
ADD_DEFINITIONS(-fvisibility=hidden)
|
||||||
|
ENDIF(NOT OS2 AND NOT SOLARIS AND NOT WINDOWS)
|
||||||
ENDIF(PHYSFS_IS_GCC4)
|
ENDIF(PHYSFS_IS_GCC4)
|
||||||
ENDIF(CMAKE_COMPILER_IS_GNUCC)
|
ENDIF(CMAKE_COMPILER_IS_GNUCC)
|
||||||
|
|
||||||
|
@ -105,7 +108,9 @@ IF(BEOS)
|
||||||
# We add this explicitly, since we don't want CMake to think this
|
# We add this explicitly, since we don't want CMake to think this
|
||||||
# is a C++ project unless we're on BeOS.
|
# is a C++ project unless we're on BeOS.
|
||||||
SET(PHYSFS_BEOS_SRCS platform/beos.cpp)
|
SET(PHYSFS_BEOS_SRCS platform/beos.cpp)
|
||||||
SET(OPTIONAL_LIBRARY_LIBS ${OPTIONAL_LIBRARY_LIBS} be root)
|
FIND_LIBRARY(BE_LIBRARY be)
|
||||||
|
FIND_LIBRARY(ROOT_LIBRARY root)
|
||||||
|
SET(OPTIONAL_LIBRARY_LIBS ${OPTIONAL_LIBRARY_LIBS} ${BE_LIBRARY} ${ROOT_LIBRARY})
|
||||||
ENDIF(BEOS)
|
ENDIF(BEOS)
|
||||||
|
|
||||||
# Almost everything is "compiled" here, but things that don't apply to the
|
# Almost everything is "compiled" here, but things that don't apply to the
|
||||||
|
@ -159,8 +164,6 @@ IF(UNIX)
|
||||||
CHECK_INCLUDE_FILE(pthread.h HAVE_PTHREAD_H)
|
CHECK_INCLUDE_FILE(pthread.h HAVE_PTHREAD_H)
|
||||||
IF(HAVE_PTHREAD_H)
|
IF(HAVE_PTHREAD_H)
|
||||||
SET(PHYSFS_HAVE_THREAD_SUPPORT TRUE)
|
SET(PHYSFS_HAVE_THREAD_SUPPORT TRUE)
|
||||||
ELSE(HAVE_PTHREAD_H)
|
|
||||||
ADD_DEFINITIONS(-DPHYSFS_NO_PTHREADS_SUPPORT=1)
|
|
||||||
ENDIF(HAVE_PTHREAD_H)
|
ENDIF(HAVE_PTHREAD_H)
|
||||||
ENDIF(BEOS)
|
ENDIF(BEOS)
|
||||||
ENDIF(UNIX)
|
ENDIF(UNIX)
|
||||||
|
@ -184,6 +187,7 @@ ENDIF(NOT PHYSFS_HAVE_CDROM_SUPPORT)
|
||||||
IF(PHYSFS_HAVE_THREAD_SUPPORT)
|
IF(PHYSFS_HAVE_THREAD_SUPPORT)
|
||||||
ADD_DEFINITIONS(-D_REENTRANT -D_THREAD_SAFE)
|
ADD_DEFINITIONS(-D_REENTRANT -D_THREAD_SAFE)
|
||||||
ELSE(PHYSFS_HAVE_THREAD_SUPPORT)
|
ELSE(PHYSFS_HAVE_THREAD_SUPPORT)
|
||||||
|
ADD_DEFINITIONS(-DPHYSFS_NO_THREAD_SUPPORT=1)
|
||||||
MESSAGE(WARNING " ***")
|
MESSAGE(WARNING " ***")
|
||||||
MESSAGE(WARNING " *** There is no thread support in this build!")
|
MESSAGE(WARNING " *** There is no thread support in this build!")
|
||||||
MESSAGE(WARNING " *** PhysicsFS will NOT be reentrant!")
|
MESSAGE(WARNING " *** PhysicsFS will NOT be reentrant!")
|
||||||
|
@ -244,26 +248,21 @@ ENDIF(PHYSFS_ARCHIVE_QPAK)
|
||||||
# See if some archiver required zlib, and see about using system version.
|
# See if some archiver required zlib, and see about using system version.
|
||||||
|
|
||||||
IF(PHYSFS_NEED_ZLIB)
|
IF(PHYSFS_NEED_ZLIB)
|
||||||
CHECK_INCLUDE_FILE(zlib.h HAVE_ZLIB_H)
|
FIND_PACKAGE(ZLIB)
|
||||||
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)
|
|
||||||
|
|
||||||
IF(HAVE_SYSTEM_ZLIB)
|
IF(ZLIB_FOUND)
|
||||||
OPTION(PHYSFS_INTERNAL_ZLIB "Link own zlib instead of system library" FALSE)
|
OPTION(PHYSFS_INTERNAL_ZLIB "Link own zlib instead of system library" FALSE)
|
||||||
ELSE(HAVE_SYSTEM_ZLIB)
|
ELSE(HAVE_SYSTEM_ZLIB)
|
||||||
SET(PHYSFS_INTERNAL_ZLIB TRUE)
|
SET(PHYSFS_INTERNAL_ZLIB TRUE)
|
||||||
ENDIF(HAVE_SYSTEM_ZLIB)
|
ENDIF(ZLIB_FOUND)
|
||||||
|
|
||||||
IF(PHYSFS_INTERNAL_ZLIB)
|
IF(PHYSFS_INTERNAL_ZLIB)
|
||||||
INCLUDE_DIRECTORIES(zlib123)
|
INCLUDE_DIRECTORIES(zlib123)
|
||||||
ADD_DEFINITIONS(-DZ_PREFIX=1)
|
ADD_DEFINITIONS(-DZ_PREFIX=1)
|
||||||
SET(PHYSFS_SRCS ${PHYSFS_SRCS} ${ZLIB_SRCS})
|
SET(PHYSFS_SRCS ${PHYSFS_SRCS} ${ZLIB_SRCS})
|
||||||
ELSE(PHYSFS_INTERNAL_ZLIB)
|
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_INTERNAL_ZLIB)
|
||||||
ENDIF(PHYSFS_NEED_ZLIB)
|
ENDIF(PHYSFS_NEED_ZLIB)
|
||||||
|
|
||||||
|
@ -298,18 +297,20 @@ ENDIF(PHYSFS_BUILD_SHARED AND PHYSFS_BUILD_STATIC)
|
||||||
OPTION(PHYSFS_BUILD_TEST "Build stdio test program." TRUE)
|
OPTION(PHYSFS_BUILD_TEST "Build stdio test program." TRUE)
|
||||||
MARK_AS_ADVANCED(PHYSFS_BUILD_TEST)
|
MARK_AS_ADVANCED(PHYSFS_BUILD_TEST)
|
||||||
IF(PHYSFS_BUILD_TEST)
|
IF(PHYSFS_BUILD_TEST)
|
||||||
CHECK_INCLUDE_FILE(readline/readline.h HAVE_READLINE_H)
|
FIND_PATH(READLINE_H readline/readline.h)
|
||||||
CHECK_INCLUDE_FILE(readline/history.h HAVE_HISTORY_H)
|
FIND_PATH(HISTORY_H readline/history.h)
|
||||||
IF(HAVE_READLINE_H AND HAVE_HISTORY_H)
|
IF(READLINE_H AND HISTORY_H)
|
||||||
SET(CMAKE_REQUIRED_LIBRARIES curses)
|
FIND_LIBRARY(CURSES_LIBRARY NAMES curses ncurses)
|
||||||
CHECK_LIBRARY_EXISTS("readline" "readline" "" HAVE_LIBREADLINE)
|
SET(CMAKE_REQUIRED_LIBRARIES ${CURSES_LIBRARY})
|
||||||
CHECK_LIBRARY_EXISTS("readline" "history" "" HAVE_LIBHISTORY)
|
FIND_LIBRARY(READLINE_LIBRARY readline)
|
||||||
IF(HAVE_LIBREADLINE AND HAVE_LIBHISTORY)
|
FIND_LIBRARY(HISTORY_LIBRARY history)
|
||||||
|
IF(READLINE_LIBRARY AND HISTORY_LIBRARY)
|
||||||
SET(HAVE_SYSTEM_READLINE TRUE)
|
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)
|
ADD_DEFINITIONS(-DPHYSFS_HAVE_READLINE=1)
|
||||||
ENDIF(HAVE_LIBREADLINE AND HAVE_LIBHISTORY)
|
ENDIF(READLINE_LIBRARY AND HISTORY_LIBRARY)
|
||||||
ENDIF(HAVE_READLINE_H AND HAVE_HISTORY_H)
|
ENDIF(READLINE_H AND HISTORY_H)
|
||||||
ADD_EXECUTABLE(test_physfs test/test_physfs.c)
|
ADD_EXECUTABLE(test_physfs test/test_physfs.c)
|
||||||
TARGET_LINK_LIBRARIES(test_physfs ${PHYSFS_LIB_TARGET} ${TEST_PHYSFS_LIBS} ${OTHER_LDFLAGS})
|
TARGET_LINK_LIBRARIES(test_physfs ${PHYSFS_LIB_TARGET} ${TEST_PHYSFS_LIBS} ${OTHER_LDFLAGS})
|
||||||
SET(PHYSFS_INSTALL_TARGETS ${PHYSFS_INSTALL_TARGETS} ";test_physfs")
|
SET(PHYSFS_INSTALL_TARGETS ${PHYSFS_INSTALL_TARGETS} ";test_physfs")
|
||||||
|
@ -335,8 +336,8 @@ ENDIF(PHYSFS_BUILD_WX_TEST)
|
||||||
|
|
||||||
INSTALL(TARGETS ${PHYSFS_INSTALL_TARGETS}
|
INSTALL(TARGETS ${PHYSFS_INSTALL_TARGETS}
|
||||||
RUNTIME DESTINATION bin
|
RUNTIME DESTINATION bin
|
||||||
LIBRARY DESTINATION lib
|
LIBRARY DESTINATION lib${LIB_SUFFIX}
|
||||||
ARCHIVE DESTINATION lib)
|
ARCHIVE DESTINATION lib${LIB_SUFFIX})
|
||||||
INSTALL(FILES physfs.h DESTINATION include)
|
INSTALL(FILES physfs.h DESTINATION include)
|
||||||
|
|
||||||
FIND_PACKAGE(Doxygen)
|
FIND_PACKAGE(Doxygen)
|
||||||
|
@ -347,7 +348,13 @@ ELSE(DOXYGEN_FOUND)
|
||||||
ENDIF(DOXYGEN_FOUND)
|
ENDIF(DOXYGEN_FOUND)
|
||||||
|
|
||||||
IF(UNIX)
|
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)
|
ENDIF(UNIX)
|
||||||
|
|
||||||
MACRO(MESSAGE_BOOL_OPTION _NAME _VALUE)
|
MACRO(MESSAGE_BOOL_OPTION _NAME _VALUE)
|
||||||
|
|
|
@ -90,6 +90,12 @@ Bug fixes:
|
||||||
Bug fixes:
|
Bug fixes:
|
||||||
Olivier Boudeville
|
Olivier Boudeville
|
||||||
|
|
||||||
|
Bug fixes:
|
||||||
|
Henk Boom
|
||||||
|
|
||||||
|
Build system fixes:
|
||||||
|
Marc Kleine-Budde
|
||||||
|
|
||||||
Windows .rc file,
|
Windows .rc file,
|
||||||
7zip/lzma archiver:
|
7zip/lzma archiver:
|
||||||
Dennis Schridde
|
Dennis Schridde
|
||||||
|
@ -97,6 +103,9 @@ Windows .rc file,
|
||||||
OS/2 updates:
|
OS/2 updates:
|
||||||
Dave Yeo
|
Dave Yeo
|
||||||
|
|
||||||
|
Bug fixes:
|
||||||
|
Patrice Mandin
|
||||||
|
|
||||||
Other stuff:
|
Other stuff:
|
||||||
Your name here! Patches go to icculus@icculus.org ...
|
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
|
# This could be handy for archiving the generated documentation or
|
||||||
# if some version control system is used.
|
# if some version control system is used.
|
||||||
|
|
||||||
PROJECT_NUMBER = 2.0.0
|
PROJECT_NUMBER = 2.0.2
|
||||||
|
|
||||||
# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute)
|
# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute)
|
||||||
# base path where the generated documentation will be put.
|
# base path where the generated documentation will be put.
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
|
|
||||||
Copyright (c) 2003-2009 Ryan C. Gordon and others.
|
Copyright (c) 2001-2011 Ryan C. Gordon and others.
|
||||||
|
|
||||||
This software is provided 'as-is', without any express or implied warranty.
|
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
|
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,
|
SZ_RESULT SzFileReadImp(void *object, void **buffer, size_t maxReqSize,
|
||||||
size_t *processedSize)
|
size_t *processedSize)
|
||||||
{
|
{
|
||||||
FileInputStream *s = (FileInputStream *)(object - offsetof(FileInputStream, inStream)); // HACK!
|
FileInputStream *s = (FileInputStream *)(object - offsetof(FileInputStream, inStream)); /* HACK! */
|
||||||
PHYSFS_sint64 processedSizeLoc = 0;
|
PHYSFS_sint64 processedSizeLoc = 0;
|
||||||
|
|
||||||
if (maxReqSize > BUFFER_SIZE)
|
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,
|
SZ_RESULT SzFileReadImp(void *object, void *buffer, size_t size,
|
||||||
size_t *processedSize)
|
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);
|
size_t processedSizeLoc = __PHYSFS_platformRead(s->file, buffer, 1, size);
|
||||||
if (processedSize != 0)
|
if (processedSize != 0)
|
||||||
*processedSize = processedSizeLoc;
|
*processedSize = processedSizeLoc;
|
||||||
|
@ -145,7 +145,7 @@ SZ_RESULT SzFileReadImp(void *object, void *buffer, size_t size,
|
||||||
*/
|
*/
|
||||||
SZ_RESULT SzFileSeekImp(void *object, CFileSize pos)
|
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))
|
if (__PHYSFS_platformSeek(s->file, (PHYSFS_uint64) pos))
|
||||||
return SZ_OK;
|
return SZ_OK;
|
||||||
return SZE_FAIL;
|
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)
|
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);
|
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];
|
LZMAfile *file = &archive->files[fileIndex];
|
||||||
PHYSFS_uint32 folderIndex = archive->db.FileIndexToFolderIndexMap[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->archive = archive;
|
||||||
file->folder = (folderIndex != (PHYSFS_uint32)-1 ? &archive->folders[folderIndex] : NULL); // Directories don't have a folder (they contain no own data...)
|
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->item = &archive->db.Database.Files[fileIndex]; /* Holds crucial data and is often referenced -> Store link */
|
||||||
file->position = 0;
|
file->position = 0;
|
||||||
file->offset = 0; /* Offset will be set by LZMA_read() */
|
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))
|
if (!lzma_file_init(archive, fileIndex))
|
||||||
{
|
{
|
||||||
return(0); // FALSE on failure
|
return(0); /* FALSE on failure */
|
||||||
}
|
}
|
||||||
} /* for */
|
} /* for */
|
||||||
|
|
||||||
|
@ -450,7 +450,7 @@ static int LZMA_isArchive(const char *filename, int forWriting)
|
||||||
/* Read signature bytes */
|
/* Read signature bytes */
|
||||||
if (__PHYSFS_platformRead(in, sig, k7zSignatureSize, 1) != 1)
|
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);
|
BAIL_MACRO(NULL, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -478,7 +478,7 @@ static void *LZMA_openArchive(const char *name, int forWriting)
|
||||||
{
|
{
|
||||||
__PHYSFS_platformClose(archive->stream.file);
|
__PHYSFS_platformClose(archive->stream.file);
|
||||||
lzma_archive_exit(archive);
|
lzma_archive_exit(archive);
|
||||||
return(NULL); // Error is set by platformOpenRead!
|
return(NULL); /* Error is set by platformOpenRead! */
|
||||||
}
|
}
|
||||||
|
|
||||||
CrcGenerateTable();
|
CrcGenerateTable();
|
||||||
|
@ -491,7 +491,7 @@ static void *LZMA_openArchive(const char *name, int forWriting)
|
||||||
SzArDbExFree(&archive->db, SzFreePhysicsFS);
|
SzArDbExFree(&archive->db, SzFreePhysicsFS);
|
||||||
__PHYSFS_platformClose(archive->stream.file);
|
__PHYSFS_platformClose(archive->stream.file);
|
||||||
lzma_archive_exit(archive);
|
lzma_archive_exit(archive);
|
||||||
return NULL; // Error is set by lzma_err!
|
return NULL; /* Error is set by lzma_err! */
|
||||||
} /* if */
|
} /* if */
|
||||||
|
|
||||||
len = archive->db.Database.NumFiles * sizeof (LZMAfile);
|
len = archive->db.Database.NumFiles * sizeof (LZMAfile);
|
||||||
|
@ -568,7 +568,7 @@ static void LZMA_enumerateFiles(dvoid *opaque, const char *dname,
|
||||||
if (dlen)
|
if (dlen)
|
||||||
{
|
{
|
||||||
file = lzma_find_file(archive, dname);
|
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;
|
file += 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -617,7 +617,7 @@ static PHYSFS_sint64 LZMA_getLastModTime(dvoid *opaque,
|
||||||
*fileExists = (file != NULL);
|
*fileExists = (file != NULL);
|
||||||
|
|
||||||
BAIL_IF_MACRO(file == NULL, NULL, -1);
|
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));
|
return(lzma_filetime_to_unix_timestamp(&file->item->LastWriteTime));
|
||||||
} /* LZMA_getLastModTime */
|
} /* 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 == NULL, ERR_NO_SUCH_FILE, NULL);
|
||||||
BAIL_IF_MACRO(file->folder == NULL, ERR_NOT_A_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);
|
return(file);
|
||||||
} /* LZMA_openRead */
|
} /* LZMA_openRead */
|
||||||
|
|
|
@ -478,8 +478,11 @@ static QPAKentry *qpak_find_entry(QPAKinfo *info, const char *path, int *isDir)
|
||||||
|
|
||||||
if (thispath[pathlen] == '\0') /* found entry? */
|
if (thispath[pathlen] == '\0') /* found entry? */
|
||||||
return(&a[middle]);
|
return(&a[middle]);
|
||||||
|
/* adjust search params, try again. */
|
||||||
|
else if (thispath[pathlen] > '/')
|
||||||
|
hi = middle - 1;
|
||||||
else
|
else
|
||||||
hi = middle - 1; /* adjust search params, try again. */
|
lo = middle + 1;
|
||||||
} /* if */
|
} /* if */
|
||||||
} /* while */
|
} /* while */
|
||||||
|
|
||||||
|
|
|
@ -375,7 +375,7 @@ static int ZIP_fileClose(fvoid *opaque)
|
||||||
static PHYSFS_sint64 zip_find_end_of_central_dir(void *in, PHYSFS_sint64 *len)
|
static PHYSFS_sint64 zip_find_end_of_central_dir(void *in, PHYSFS_sint64 *len)
|
||||||
{
|
{
|
||||||
PHYSFS_uint8 buf[256];
|
PHYSFS_uint8 buf[256];
|
||||||
PHYSFS_uint8 extra[4];
|
PHYSFS_uint8 extra[4] = { 0, 0, 0, 0 };
|
||||||
PHYSFS_sint32 i = 0;
|
PHYSFS_sint32 i = 0;
|
||||||
PHYSFS_sint64 filelen;
|
PHYSFS_sint64 filelen;
|
||||||
PHYSFS_sint64 filepos;
|
PHYSFS_sint64 filepos;
|
||||||
|
@ -544,8 +544,11 @@ static ZIPentry *zip_find_entry(ZIPinfo *info, const char *path, int *isDir)
|
||||||
|
|
||||||
if (thispath[pathlen] == '\0') /* found entry? */
|
if (thispath[pathlen] == '\0') /* found entry? */
|
||||||
return(&a[middle]);
|
return(&a[middle]);
|
||||||
|
/* adjust search params, try again. */
|
||||||
|
else if (thispath[pathlen] > '/')
|
||||||
|
hi = middle - 1;
|
||||||
else
|
else
|
||||||
hi = middle - 1; /* adjust search params, try again. */
|
lo = middle + 1;
|
||||||
} /* if */
|
} /* if */
|
||||||
} /* while */
|
} /* while */
|
||||||
|
|
||||||
|
|
|
@ -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");
|
printf("out of memory.\n");
|
||||||
return;
|
return;
|
||||||
} // if
|
} /* if */
|
||||||
args->addr = (struct sockaddr *) malloc(addrlen);
|
args->addr = (struct sockaddr *) malloc(addrlen);
|
||||||
if (args->addr == NULL)
|
if (args->addr == NULL)
|
||||||
{
|
{
|
||||||
free(args);
|
free(args);
|
||||||
printf("out of memory.\n");
|
printf("out of memory.\n");
|
||||||
return;
|
return;
|
||||||
} // if
|
} /* if */
|
||||||
|
|
||||||
args->sock = sock;
|
args->sock = sock;
|
||||||
args->addrlen = addrlen;
|
args->addrlen = addrlen;
|
||||||
|
|
|
@ -2,6 +2,10 @@
|
||||||
|
|
||||||
#include <memory.h>
|
#include <memory.h>
|
||||||
|
|
||||||
|
/* BEGIN PHYSFS CHANGE */
|
||||||
|
#include <string.h>
|
||||||
|
/* END PHYSFS CHANGE */
|
||||||
|
|
||||||
#include "7zDecode.h"
|
#include "7zDecode.h"
|
||||||
#ifdef _SZ_ONE_DIRECTORY
|
#ifdef _SZ_ONE_DIRECTORY
|
||||||
#include "LzmaDecode.h"
|
#include "LzmaDecode.h"
|
||||||
|
|
24
physfs.c
24
physfs.c
|
@ -605,18 +605,21 @@ static int freeDirHandle(DirHandle *dh, FileHandle *openList)
|
||||||
|
|
||||||
static char *calculateUserDir(void)
|
static char *calculateUserDir(void)
|
||||||
{
|
{
|
||||||
char *retval = NULL;
|
char *retval = __PHYSFS_platformGetUserDir();
|
||||||
const char *str = NULL;
|
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 (retval == NULL)
|
||||||
if (str != NULL)
|
|
||||||
retval = (char *) str;
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
const char *dirsep = PHYSFS_getDirSeparator();
|
const char *dirsep = PHYSFS_getDirSeparator();
|
||||||
const char *uname = __PHYSFS_platformGetUserName();
|
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) +
|
retval = (char *) allocator.Malloc(strlen(baseDir) + strlen(str) +
|
||||||
strlen(dirsep) + 6);
|
strlen(dirsep) + 6);
|
||||||
|
|
||||||
|
@ -754,13 +757,6 @@ int PHYSFS_init(const char *argv0)
|
||||||
BAIL_IF_MACRO(!appendDirSep(&baseDir), NULL, 0);
|
BAIL_IF_MACRO(!appendDirSep(&baseDir), NULL, 0);
|
||||||
|
|
||||||
userDir = calculateUserDir();
|
userDir = calculateUserDir();
|
||||||
if (userDir != NULL)
|
|
||||||
{
|
|
||||||
ptr = __PHYSFS_platformRealPath(userDir);
|
|
||||||
allocator.Free(userDir);
|
|
||||||
userDir = ptr;
|
|
||||||
} /* if */
|
|
||||||
|
|
||||||
if ((userDir == NULL) || (!appendDirSep(&userDir)))
|
if ((userDir == NULL) || (!appendDirSep(&userDir)))
|
||||||
{
|
{
|
||||||
allocator.Free(baseDir);
|
allocator.Free(baseDir);
|
||||||
|
|
26
physfs.h
26
physfs.h
|
@ -1,4 +1,8 @@
|
||||||
/** \file physfs.h */
|
/**
|
||||||
|
* \file physfs.h
|
||||||
|
*
|
||||||
|
* Main header file for PhysicsFS.
|
||||||
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \mainpage PhysicsFS
|
* \mainpage PhysicsFS
|
||||||
|
@ -401,7 +405,7 @@ typedef struct PHYSFS_Version
|
||||||
#ifndef DOXYGEN_SHOULD_IGNORE_THIS
|
#ifndef DOXYGEN_SHOULD_IGNORE_THIS
|
||||||
#define PHYSFS_VER_MAJOR 2
|
#define PHYSFS_VER_MAJOR 2
|
||||||
#define PHYSFS_VER_MINOR 0
|
#define PHYSFS_VER_MINOR 0
|
||||||
#define PHYSFS_VER_PATCH 0
|
#define PHYSFS_VER_PATCH 2
|
||||||
#endif /* DOXYGEN_SHOULD_IGNORE_THIS */
|
#endif /* DOXYGEN_SHOULD_IGNORE_THIS */
|
||||||
|
|
||||||
|
|
||||||
|
@ -986,7 +990,7 @@ __EXPORT__ const char *PHYSFS_getRealDir(const char *filename);
|
||||||
* PHYSFS_freeList(rc);
|
* PHYSFS_freeList(rc);
|
||||||
* \endcode
|
* \endcode
|
||||||
*
|
*
|
||||||
* ...will print:
|
* \...will print:
|
||||||
*
|
*
|
||||||
* \verbatim
|
* \verbatim
|
||||||
* We've got [x.sav].
|
* We've got [x.sav].
|
||||||
|
@ -1211,9 +1215,9 @@ __EXPORT__ PHYSFS_sint64 PHYSFS_read(PHYSFS_File *handle,
|
||||||
* The file must be opened for writing.
|
* The file must be opened for writing.
|
||||||
*
|
*
|
||||||
* \param handle retval from PHYSFS_openWrite() or PHYSFS_openAppend().
|
* \param handle retval from PHYSFS_openWrite() or PHYSFS_openAppend().
|
||||||
* \param buffer buffer to store read data into.
|
* \param buffer buffer of bytes to write to (handle).
|
||||||
* \param objSize size in bytes of objects being read from (handle).
|
* \param objSize size in bytes of objects being written to (handle).
|
||||||
* \param objCount number of (objSize) objects to read from (handle).
|
* \param objCount number of (objSize) objects to write to (handle).
|
||||||
* \return number of objects written. PHYSFS_getLastError() can shed light on
|
* \return number of objects written. PHYSFS_getLastError() can shed light on
|
||||||
* the reason this might be < (objCount). -1 if complete failure.
|
* the reason this might be < (objCount). -1 if complete failure.
|
||||||
*/
|
*/
|
||||||
|
@ -2268,7 +2272,7 @@ __EXPORT__ void PHYSFS_enumerateFilesCallback(const char *dir,
|
||||||
*
|
*
|
||||||
* Strings that don't fit in the destination buffer will be truncated, but
|
* Strings that don't fit in the destination buffer will be truncated, but
|
||||||
* will always be null-terminated and never have an incomplete UTF-8
|
* will always be null-terminated and never have an incomplete UTF-8
|
||||||
* sequence at the end.
|
* sequence at the end. If the buffer length is 0, this function does nothing.
|
||||||
*
|
*
|
||||||
* \param src Null-terminated source string in UCS-4 format.
|
* \param src Null-terminated source string in UCS-4 format.
|
||||||
* \param dst Buffer to store converted UTF-8 string.
|
* \param dst Buffer to store converted UTF-8 string.
|
||||||
|
@ -2290,7 +2294,7 @@ __EXPORT__ void PHYSFS_utf8FromUcs4(const PHYSFS_uint32 *src, char *dst,
|
||||||
*
|
*
|
||||||
* Strings that don't fit in the destination buffer will be truncated, but
|
* Strings that don't fit in the destination buffer will be truncated, but
|
||||||
* will always be null-terminated and never have an incomplete UCS-4
|
* will always be null-terminated and never have an incomplete UCS-4
|
||||||
* sequence at the end.
|
* sequence at the end. If the buffer length is 0, this function does nothing.
|
||||||
*
|
*
|
||||||
* \param src Null-terminated source string in UTF-8 format.
|
* \param src Null-terminated source string in UTF-8 format.
|
||||||
* \param dst Buffer to store converted UCS-4 string.
|
* \param dst Buffer to store converted UCS-4 string.
|
||||||
|
@ -2313,7 +2317,7 @@ __EXPORT__ void PHYSFS_utf8ToUcs4(const char *src, PHYSFS_uint32 *dst,
|
||||||
*
|
*
|
||||||
* Strings that don't fit in the destination buffer will be truncated, but
|
* Strings that don't fit in the destination buffer will be truncated, but
|
||||||
* will always be null-terminated and never have an incomplete UTF-8
|
* will always be null-terminated and never have an incomplete UTF-8
|
||||||
* sequence at the end.
|
* sequence at the end. If the buffer length is 0, this function does nothing.
|
||||||
*
|
*
|
||||||
* Please note that UCS-2 is not UTF-16; we do not support the "surrogate"
|
* Please note that UCS-2 is not UTF-16; we do not support the "surrogate"
|
||||||
* values at this time.
|
* values at this time.
|
||||||
|
@ -2339,7 +2343,7 @@ __EXPORT__ void PHYSFS_utf8FromUcs2(const PHYSFS_uint16 *src, char *dst,
|
||||||
*
|
*
|
||||||
* Strings that don't fit in the destination buffer will be truncated, but
|
* Strings that don't fit in the destination buffer will be truncated, but
|
||||||
* will always be null-terminated and never have an incomplete UCS-2
|
* will always be null-terminated and never have an incomplete UCS-2
|
||||||
* sequence at the end.
|
* sequence at the end. If the buffer length is 0, this function does nothing.
|
||||||
*
|
*
|
||||||
* Please note that UCS-2 is not UTF-16; we do not support the "surrogate"
|
* Please note that UCS-2 is not UTF-16; we do not support the "surrogate"
|
||||||
* values at this time.
|
* values at this time.
|
||||||
|
@ -2365,7 +2369,7 @@ __EXPORT__ void PHYSFS_utf8ToUcs2(const char *src, PHYSFS_uint16 *dst,
|
||||||
*
|
*
|
||||||
* Strings that don't fit in the destination buffer will be truncated, but
|
* Strings that don't fit in the destination buffer will be truncated, but
|
||||||
* will always be null-terminated and never have an incomplete UTF-8
|
* will always be null-terminated and never have an incomplete UTF-8
|
||||||
* sequence at the end.
|
* sequence at the end. If the buffer length is 0, this function does nothing.
|
||||||
*
|
*
|
||||||
* Please note that we do not supply a UTF-8 to Latin1 converter, since Latin1
|
* Please note that we do not supply a UTF-8 to Latin1 converter, since Latin1
|
||||||
* can't express most Unicode codepoints. It's a legacy encoding; you should
|
* can't express most Unicode codepoints. It's a legacy encoding; you should
|
||||||
|
|
|
@ -29,6 +29,10 @@
|
||||||
#include <malloc.h>
|
#include <malloc.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(__sun) || defined(sun)
|
||||||
|
#include <alloca.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
@ -966,7 +970,7 @@ char *__PHYSFS_convertToDependent(const char *prepend,
|
||||||
#define PHYSFS_LIL_ENDIAN 1234
|
#define PHYSFS_LIL_ENDIAN 1234
|
||||||
#define PHYSFS_BIG_ENDIAN 4321
|
#define PHYSFS_BIG_ENDIAN 4321
|
||||||
|
|
||||||
#if defined(__i386__) || defined(__ia64__) || defined(WIN32) || \
|
#if defined(__i386__) || defined(__ia64__) || defined(_M_IX86) || defined(_M_IA64) || \
|
||||||
(defined(__alpha__) || defined(__alpha)) || \
|
(defined(__alpha__) || defined(__alpha)) || \
|
||||||
defined(__arm__) || defined(ARM) || \
|
defined(__arm__) || defined(ARM) || \
|
||||||
(defined(__mips__) && defined(__MIPSEL__)) || \
|
(defined(__mips__) && defined(__MIPSEL__)) || \
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
#elif ((defined __MACH__) && (defined __APPLE__))
|
#elif ((defined __MACH__) && (defined __APPLE__))
|
||||||
/* To check if iphone or not, we need to include this file */
|
/* To check if iphone or not, we need to include this file */
|
||||||
# include <TargetConditionals.h>
|
# 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_UNIX
|
||||||
# define PHYSFS_PLATFORM_POSIX
|
# define PHYSFS_PLATFORM_POSIX
|
||||||
# define PHYSFS_NO_CDROM_SUPPORT
|
# define PHYSFS_NO_CDROM_SUPPORT
|
||||||
|
|
|
@ -305,10 +305,11 @@ static void utf8fromcodepoint(PHYSFS_uint32 cp, char **_dst, PHYSFS_uint64 *_len
|
||||||
} /* utf8fromcodepoint */
|
} /* utf8fromcodepoint */
|
||||||
|
|
||||||
#define UTF8FROMTYPE(typ, src, dst, len) \
|
#define UTF8FROMTYPE(typ, src, dst, len) \
|
||||||
|
if (len == 0) return; \
|
||||||
len--; \
|
len--; \
|
||||||
while (len) \
|
while (len) \
|
||||||
{ \
|
{ \
|
||||||
const PHYSFS_uint32 cp = (PHYSFS_uint32) *(src++); \
|
const PHYSFS_uint32 cp = (PHYSFS_uint32) ((typ) (*(src++))); \
|
||||||
if (cp == 0) break; \
|
if (cp == 0) break; \
|
||||||
utf8fromcodepoint(cp, &dst, &len); \
|
utf8fromcodepoint(cp, &dst, &len); \
|
||||||
} \
|
} \
|
||||||
|
|
|
@ -174,14 +174,17 @@ static team_id getTeamID(void)
|
||||||
|
|
||||||
char *__PHYSFS_platformCalcBaseDir(const char *argv0)
|
char *__PHYSFS_platformCalcBaseDir(const char *argv0)
|
||||||
{
|
{
|
||||||
/* in case there isn't a BApplication yet, we'll construct a roster. */
|
image_info info;
|
||||||
BRoster roster;
|
int32 cookie = 0;
|
||||||
app_info info;
|
|
||||||
status_t rc = roster.GetRunningAppInfo(getTeamID(), &info);
|
while (get_next_image_info(0, &cookie, &info) == B_OK) {
|
||||||
BAIL_IF_MACRO(rc < B_OK, strerror(rc), NULL);
|
if (info.type == B_APP_IMAGE)
|
||||||
BEntry entry(&(info.ref), true);
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
BEntry entry(info.name, true);
|
||||||
BPath path;
|
BPath path;
|
||||||
rc = entry.GetPath(&path); /* (path) now has binary's path. */
|
status_t rc = entry.GetPath(&path); /* (path) now has binary's path. */
|
||||||
assert(rc == B_OK);
|
assert(rc == B_OK);
|
||||||
rc = path.GetParent(&path); /* chop filename, keep directory. */
|
rc = path.GetParent(&path); /* chop filename, keep directory. */
|
||||||
assert(rc == B_OK);
|
assert(rc == B_OK);
|
||||||
|
|
|
@ -604,13 +604,13 @@ int __PHYSFS_platformEOF(void *opaque)
|
||||||
|
|
||||||
int __PHYSFS_platformFlush(void *opaque)
|
int __PHYSFS_platformFlush(void *opaque)
|
||||||
{
|
{
|
||||||
return(os2err(DosResetBuffer((HFILE) opaque) == NO_ERROR));
|
return(os2err(DosResetBuffer((HFILE) opaque)) == NO_ERROR);
|
||||||
} /* __PHYSFS_platformFlush */
|
} /* __PHYSFS_platformFlush */
|
||||||
|
|
||||||
|
|
||||||
int __PHYSFS_platformClose(void *opaque)
|
int __PHYSFS_platformClose(void *opaque)
|
||||||
{
|
{
|
||||||
return(os2err(DosClose((HFILE) opaque) == NO_ERROR));
|
return(os2err(DosClose((HFILE) opaque)) == NO_ERROR);
|
||||||
} /* __PHYSFS_platformClose */
|
} /* __PHYSFS_platformClose */
|
||||||
|
|
||||||
|
|
||||||
|
@ -619,7 +619,7 @@ int __PHYSFS_platformDelete(const char *path)
|
||||||
if (__PHYSFS_platformIsDirectory(path))
|
if (__PHYSFS_platformIsDirectory(path))
|
||||||
return(os2err(DosDeleteDir(path)) == NO_ERROR);
|
return(os2err(DosDeleteDir(path)) == NO_ERROR);
|
||||||
|
|
||||||
return(os2err(DosDelete(path) == NO_ERROR));
|
return(os2err(DosDelete(path)) == NO_ERROR);
|
||||||
} /* __PHYSFS_platformDelete */
|
} /* __PHYSFS_platformDelete */
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -331,8 +331,8 @@ static void *doOpen(const char *fname, DWORD mode, DWORD creation, int rdonly)
|
||||||
wchar_t *w_fname = NULL;
|
wchar_t *w_fname = NULL;
|
||||||
|
|
||||||
UTF8_TO_UNICODE_STACK_MACRO(w_fname, fname);
|
UTF8_TO_UNICODE_STACK_MACRO(w_fname, fname);
|
||||||
fileHandle = CreateFile(w_fname, mode, FILE_SHARE_READ, NULL,
|
fileHandle = CreateFile(w_fname, mode, FILE_SHARE_READ | FILE_SHARE_WRITE,
|
||||||
creation, FILE_ATTRIBUTE_NORMAL, NULL);
|
NULL, creation, FILE_ATTRIBUTE_NORMAL, NULL);
|
||||||
__PHYSFS_smallFree(w_fname);
|
__PHYSFS_smallFree(w_fname);
|
||||||
|
|
||||||
BAIL_IF_MACRO(fileHandle == INVALID_HANDLE_VALUE, win32strerror(), NULL);
|
BAIL_IF_MACRO(fileHandle == INVALID_HANDLE_VALUE, win32strerror(), NULL);
|
||||||
|
|
|
@ -97,8 +97,21 @@ char *__PHYSFS_platformGetUserName(void)
|
||||||
char *__PHYSFS_platformGetUserDir(void)
|
char *__PHYSFS_platformGetUserDir(void)
|
||||||
{
|
{
|
||||||
char *retval = __PHYSFS_platformCopyEnvironmentVariable("HOME");
|
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)
|
if (retval == NULL)
|
||||||
retval = getUserDirByUID();
|
retval = getUserDirByUID();
|
||||||
|
|
||||||
return(retval);
|
return(retval);
|
||||||
} /* __PHYSFS_platformGetUserDir */
|
} /* __PHYSFS_platformGetUserDir */
|
||||||
|
|
||||||
|
|
|
@ -23,9 +23,8 @@
|
||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <sys/mount.h>
|
|
||||||
|
|
||||||
#if (!defined PHYSFS_NO_PTHREADS_SUPPORT)
|
#if (!defined PHYSFS_NO_THREAD_SUPPORT)
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -34,6 +33,7 @@
|
||||||
# undef PHYSFS_HAVE_MNTENT_H /* don't do both... */
|
# undef PHYSFS_HAVE_MNTENT_H /* don't do both... */
|
||||||
# endif
|
# endif
|
||||||
# include <sys/ucred.h>
|
# include <sys/ucred.h>
|
||||||
|
# include <sys/mount.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef PHYSFS_HAVE_MNTENT_H
|
#ifdef PHYSFS_HAVE_MNTENT_H
|
||||||
|
@ -42,6 +42,9 @@
|
||||||
|
|
||||||
#include "physfs_internal.h"
|
#include "physfs_internal.h"
|
||||||
|
|
||||||
|
#ifndef MAXPATHLEN
|
||||||
|
#define MAXPATHLEN 1024
|
||||||
|
#endif
|
||||||
|
|
||||||
int __PHYSFS_platformInit(void)
|
int __PHYSFS_platformInit(void)
|
||||||
{
|
{
|
||||||
|
@ -101,6 +104,14 @@ void __PHYSFS_platformDetectAvailableCDs(PHYSFS_StringCallback cb, void *data)
|
||||||
int add_it = 0;
|
int add_it = 0;
|
||||||
if (strcmp(ent->mnt_type, "iso9660") == 0)
|
if (strcmp(ent->mnt_type, "iso9660") == 0)
|
||||||
add_it = 1;
|
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 */
|
/* add other mount types here */
|
||||||
|
|
||||||
|
@ -182,12 +193,42 @@ static char *findBinaryInPath(const char *bin, char *envr)
|
||||||
} /* findBinaryInPath */
|
} /* 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)
|
char *__PHYSFS_platformCalcBaseDir(const char *argv0)
|
||||||
{
|
{
|
||||||
const char *PROC_SELF_EXE = "/proc/self/exe";
|
|
||||||
char *retval = NULL;
|
char *retval = NULL;
|
||||||
char *envr = NULL;
|
char *envr = NULL;
|
||||||
struct stat stbuf;
|
|
||||||
|
|
||||||
/* fast path: default behaviour can handle this. */
|
/* fast path: default behaviour can handle this. */
|
||||||
if ( (argv0 != NULL) && (strchr(argv0, '/') != NULL) )
|
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
|
* /proc filesystem, you can get the full path to the current process from
|
||||||
* the /proc/self/exe symlink.
|
* 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;
|
/* older kernels don't have /proc/self ... try PID version... */
|
||||||
char *buf = (char *) allocator.Malloc(len+1);
|
const unsigned long long pid = (unsigned long long) getpid();
|
||||||
if (buf != NULL) /* if NULL, maybe you'll get lucky later. */
|
char path[64];
|
||||||
{
|
const int rc = (int) snprintf(path,sizeof(path),"/proc/%llu/exe",pid);
|
||||||
if (readlink(PROC_SELF_EXE, buf, len) != len)
|
if ( (rc > 0) && (rc < sizeof(path)) )
|
||||||
allocator.Free(buf);
|
retval = readSymLink(path);
|
||||||
else
|
|
||||||
{
|
|
||||||
buf[len] = '\0'; /* readlink doesn't null-terminate. */
|
|
||||||
retval = buf; /* we're good to go. */
|
|
||||||
} /* else */
|
|
||||||
} /* if */
|
} /* if */
|
||||||
|
|
||||||
|
if (retval != NULL) /* chop off filename. */
|
||||||
|
{
|
||||||
|
char *ptr = strrchr(retval, '/');
|
||||||
|
if (ptr != NULL)
|
||||||
|
*ptr = '\0';
|
||||||
} /* if */
|
} /* if */
|
||||||
|
|
||||||
if ((retval == NULL) && (argv0 != NULL))
|
if ((retval == NULL) && (argv0 != NULL))
|
||||||
|
@ -223,6 +266,14 @@ char *__PHYSFS_platformCalcBaseDir(const char *argv0)
|
||||||
allocator.Free(envr);
|
allocator.Free(envr);
|
||||||
} /* if */
|
} /* 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);
|
return(retval);
|
||||||
} /* __PHYSFS_platformCalcBaseDir */
|
} /* __PHYSFS_platformCalcBaseDir */
|
||||||
|
|
||||||
|
@ -289,7 +340,7 @@ int __PHYSFS_platformSetDefaultAllocator(PHYSFS_Allocator *a)
|
||||||
} /* __PHYSFS_platformSetDefaultAllocator */
|
} /* __PHYSFS_platformSetDefaultAllocator */
|
||||||
|
|
||||||
|
|
||||||
#if (defined PHYSFS_NO_PTHREADS_SUPPORT)
|
#if (defined PHYSFS_NO_THREAD_SUPPORT)
|
||||||
|
|
||||||
PHYSFS_uint64 __PHYSFS_platformGetThreadID(void) { return(0x0001); }
|
PHYSFS_uint64 __PHYSFS_platformGetThreadID(void) { return(0x0001); }
|
||||||
void *__PHYSFS_platformCreateMutex(void) { return((void *) 0x0001); }
|
void *__PHYSFS_platformCreateMutex(void) { return((void *) 0x0001); }
|
||||||
|
@ -387,7 +438,7 @@ void __PHYSFS_platformReleaseMutex(void *mutex)
|
||||||
} /* if */
|
} /* if */
|
||||||
} /* __PHYSFS_platformReleaseMutex */
|
} /* __PHYSFS_platformReleaseMutex */
|
||||||
|
|
||||||
#endif /* !PHYSFS_NO_PTHREADS_SUPPORT */
|
#endif /* !PHYSFS_NO_THREAD_SUPPORT */
|
||||||
|
|
||||||
#endif /* PHYSFS_PLATFORM_UNIX */
|
#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);
|
UTF8_TO_UNICODE_STACK_MACRO(wfname, fname);
|
||||||
BAIL_IF_MACRO(wfname == NULL, ERR_OUT_OF_MEMORY, NULL);
|
BAIL_IF_MACRO(wfname == NULL, ERR_OUT_OF_MEMORY, NULL);
|
||||||
fileHandle = pCreateFileW(wfname, mode, FILE_SHARE_READ, NULL,
|
fileHandle = pCreateFileW(wfname, mode, FILE_SHARE_READ | FILE_SHARE_WRITE,
|
||||||
creation, FILE_ATTRIBUTE_NORMAL, NULL);
|
NULL, creation, FILE_ATTRIBUTE_NORMAL, NULL);
|
||||||
__PHYSFS_smallFree(wfname);
|
__PHYSFS_smallFree(wfname);
|
||||||
|
|
||||||
BAIL_IF_MACRO
|
BAIL_IF_MACRO
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
|
|
||||||
#define TEST_VERSION_MAJOR 2
|
#define TEST_VERSION_MAJOR 2
|
||||||
#define TEST_VERSION_MINOR 0
|
#define TEST_VERSION_MINOR 0
|
||||||
#define TEST_VERSION_PATCH 0
|
#define TEST_VERSION_PATCH 2
|
||||||
|
|
||||||
static FILE *history_file = NULL;
|
static FILE *history_file = NULL;
|
||||||
static PHYSFS_uint32 do_buffer_size = 0;
|
static PHYSFS_uint32 do_buffer_size = 0;
|
||||||
|
@ -1116,7 +1116,9 @@ static void open_history_file(void)
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
fgets(buf, sizeof (buf), f);
|
if (fgets(buf, sizeof (buf), f) == NULL)
|
||||||
|
break;
|
||||||
|
|
||||||
if (buf[strlen(buf) - 1] == '\n')
|
if (buf[strlen(buf) - 1] == '\n')
|
||||||
buf[strlen(buf) - 1] = '\0';
|
buf[strlen(buf) - 1] = '\0';
|
||||||
add_history(buf);
|
add_history(buf);
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
|
|
||||||
#define TEST_VER_MAJOR 2
|
#define TEST_VER_MAJOR 2
|
||||||
#define TEST_VER_MINOR 0
|
#define TEST_VER_MINOR 0
|
||||||
#define TEST_VER_PATCH 0
|
#define TEST_VER_PATCH 2
|
||||||
|
|
||||||
//static PHYSFS_uint32 do_buffer_size = 0;
|
//static PHYSFS_uint32 do_buffer_size = 0;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue