Compare commits
71 Commits
main
...
stable-2.0
Author | SHA1 | Date |
---|---|---|
Ryan C. Gordon | 4344c4fd60 | |
Ryan C. Gordon | 8d62a2c7e1 | |
Ryan C. Gordon | da8ef230b4 | |
Ryan C. Gordon | 4555bb8cd8 | |
Ryan C. Gordon | 133d4c17ff | |
Ryan C. Gordon | 1cfce370eb | |
Ryan C. Gordon | 87f4ed6786 | |
Ryan C. Gordon | 038b0fa5fa | |
Ryan C. Gordon | 783d661bf8 | |
Ryan C. Gordon | ca561d6bef | |
Ryan C. Gordon | 712c7d8c66 | |
Ryan C. Gordon | ef77bb40ba | |
Lauri Kasanen | b13e4d878d | |
Ryan C. Gordon | 69f3a2654a | |
Ryan C. Gordon | 3e0fb8c998 | |
Ryan C. Gordon | 5fe652d7ad | |
Ryan C. Gordon | 5af008eac3 | |
Ryan C. Gordon | 781f5bf419 | |
Ryan C. Gordon | c188729b12 | |
Ryan C. Gordon | fb149451b8 | |
Ryan C. Gordon | 26c1d991d4 | |
Ryan C. Gordon | b7694abe3c | |
Ryan C. Gordon | a62e315088 | |
Ryan C. Gordon | e3b622af4e | |
Ryan C. Gordon | 063afc9f18 | |
Ryan C. Gordon | f0cb6de676 | |
Ryan C. Gordon | a7d5c1d3cd | |
Ryan C. Gordon | 8cd359f517 | |
Ryan C. Gordon | cdcb169bcc | |
Ryan C. Gordon | 647867b6e4 | |
Ryan C. Gordon | 4043d09295 | |
Ryan C. Gordon | 76ffb5dde1 | |
Ryan C. Gordon | e7b69065a2 | |
Ryan C. Gordon | c0a3282b8d | |
Ryan C. Gordon | 9deb5b88c9 | |
Ryan C. Gordon | a471691b86 | |
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)
|
||||
|
||||
PROJECT(PhysicsFS)
|
||||
SET(PHYSFS_VERSION 2.0.0)
|
||||
SET(PHYSFS_VERSION 2.0.3)
|
||||
|
||||
# Increment this if/when we break backwards compatibility.
|
||||
SET(PHYSFS_SOVERSION 1)
|
||||
|
@ -21,6 +21,11 @@ IF(APPLE AND NOT MACOSX)
|
|||
SET(MACOSX TRUE)
|
||||
ENDIF(APPLE AND NOT MACOSX)
|
||||
|
||||
# For now, Haiku and BeOS are the same, as far as the build system cares.
|
||||
IF(HAIKU AND NOT BEOS)
|
||||
SET(BEOS TRUE)
|
||||
ENDIF(HAIKU AND NOT BEOS)
|
||||
|
||||
INCLUDE(CheckIncludeFile)
|
||||
INCLUDE(CheckLibraryExists)
|
||||
INCLUDE(CheckCSourceCompiles)
|
||||
|
@ -60,7 +65,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)
|
||||
|
||||
|
@ -105,7 +113,9 @@ IF(BEOS)
|
|||
# We add this explicitly, since we don't want CMake to think this
|
||||
# is a C++ project unless we're on BeOS.
|
||||
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)
|
||||
|
||||
# Almost everything is "compiled" here, but things that don't apply to the
|
||||
|
@ -159,9 +169,12 @@ 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)
|
||||
|
||||
FIND_LIBRARY(PTHREAD_LIBRARY pthread)
|
||||
IF(PTHREAD_LIBRARY)
|
||||
SET(OPTIONAL_LIBRARY_LIBS ${OPTIONAL_LIBRARY_LIBS} ${PTHREAD_LIBRARY})
|
||||
ENDIF(PTHREAD_LIBRARY)
|
||||
ENDIF(BEOS)
|
||||
ENDIF(UNIX)
|
||||
|
||||
|
@ -184,6 +197,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 +258,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,24 +307,25 @@ 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)
|
||||
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_PATH(READLINE_H readline/readline.h)
|
||||
FIND_PATH(HISTORY_H readline/history.h)
|
||||
IF(READLINE_H AND HISTORY_H)
|
||||
FIND_LIBRARY(CURSES_LIBRARY NAMES curses ncurses)
|
||||
SET(CMAKE_REQUIRED_LIBRARIES ${CURSES_LIBRARY})
|
||||
FIND_LIBRARY(READLINE_LIBRARY readline)
|
||||
IF(READLINE_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)
|
||||
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")
|
||||
ENDIF(PHYSFS_BUILD_TEST)
|
||||
|
||||
OPTION(PHYSFS_BUILD_WX_TEST "Build wxWidgets test program." TRUE)
|
||||
OPTION(PHYSFS_BUILD_WX_TEST "Build wxWidgets test program." FALSE)
|
||||
MARK_AS_ADVANCED(PHYSFS_BUILD_WX_TEST)
|
||||
IF(PHYSFS_BUILD_WX_TEST)
|
||||
SET(wxWidgets_USE_LIBS base core adv)
|
||||
|
@ -335,19 +345,41 @@ ENDIF(PHYSFS_BUILD_WX_TEST)
|
|||
|
||||
INSTALL(TARGETS ${PHYSFS_INSTALL_TARGETS}
|
||||
RUNTIME DESTINATION bin
|
||||
LIBRARY DESTINATION lib
|
||||
ARCHIVE DESTINATION lib)
|
||||
LIBRARY DESTINATION lib${LIB_SUFFIX}
|
||||
ARCHIVE DESTINATION lib${LIB_SUFFIX})
|
||||
INSTALL(FILES physfs.h DESTINATION include)
|
||||
|
||||
FIND_PACKAGE(Doxygen)
|
||||
IF(DOXYGEN_FOUND)
|
||||
ADD_CUSTOM_TARGET(docs ${DOXYGEN_EXECUTABLE} COMMENT "Building documentation")
|
||||
SET(PHYSFS_OUTPUT_DOXYFILE "${CMAKE_CURRENT_BINARY_DIR}/Doxyfile")
|
||||
CONFIGURE_FILE(
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile"
|
||||
"${PHYSFS_OUTPUT_DOXYFILE}"
|
||||
COPYONLY
|
||||
)
|
||||
FILE(APPEND "${PHYSFS_OUTPUT_DOXYFILE}" "\n\n# Below auto-generated by cmake...\n\n")
|
||||
FILE(APPEND "${PHYSFS_OUTPUT_DOXYFILE}" "PROJECT_NUMBER = ${PHYSFS_VERSION}\n")
|
||||
FILE(APPEND "${PHYSFS_OUTPUT_DOXYFILE}" "OUTPUT_DIRECTORY = ${CMAKE_CURRENT_BINARY_DIR}/docs\n")
|
||||
FILE(APPEND "${PHYSFS_OUTPUT_DOXYFILE}" "\n# End auto-generated section.\n\n")
|
||||
|
||||
ADD_CUSTOM_TARGET(
|
||||
docs
|
||||
${DOXYGEN_EXECUTABLE} "${PHYSFS_OUTPUT_DOXYFILE}"
|
||||
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
|
||||
COMMENT "Building documentation in 'docs' directory..."
|
||||
)
|
||||
ELSE(DOXYGEN_FOUND)
|
||||
MESSAGE(STATUS "Doxygen not found. You won't be able to build documentation.")
|
||||
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.bz2")
|
||||
ADD_CUSTOM_TARGET(
|
||||
dist
|
||||
hg archive -t tbz2 "${PHYSFS_TARBALL}"
|
||||
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
|
||||
COMMENT "Building source tarball '${PHYSFS_TARBALL}'..."
|
||||
)
|
||||
ENDIF(UNIX)
|
||||
|
||||
MACRO(MESSAGE_BOOL_OPTION _NAME _VALUE)
|
||||
|
@ -378,4 +410,3 @@ IF(PHYSFS_BUILD_TEST)
|
|||
ENDIF(PHYSFS_BUILD_TEST)
|
||||
|
||||
# end of CMakeLists.txt ...
|
||||
|
||||
|
|
15
CREDITS.txt
15
CREDITS.txt
|
@ -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,15 @@ Windows .rc file,
|
|||
OS/2 updates:
|
||||
Dave Yeo
|
||||
|
||||
Bug fixes:
|
||||
Patrice Mandin
|
||||
|
||||
Bug fixes:
|
||||
Lauri Kasanen
|
||||
|
||||
Bug fixes:
|
||||
Andreas Karlsson
|
||||
|
||||
Other stuff:
|
||||
Your name here! Patches go to icculus@icculus.org ...
|
||||
|
||||
|
|
4
Doxyfile
4
Doxyfile
|
@ -22,8 +22,8 @@ PROJECT_NAME = physfs
|
|||
# The PROJECT_NUMBER tag can be used to enter a project or revision number.
|
||||
# This could be handy for archiving the generated documentation or
|
||||
# if some version control system is used.
|
||||
|
||||
PROJECT_NUMBER = 2.0.0
|
||||
# (CMake will set this properly at build time. --ryan.)
|
||||
PROJECT_NUMBER = "unknown version (build with 'make docs' next time!)"
|
||||
|
||||
# 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) 2001-2017 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 */
|
||||
|
|
|
@ -478,8 +478,11 @@ static QPAKentry *qpak_find_entry(QPAKinfo *info, const char *path, int *isDir)
|
|||
|
||||
if (thispath[pathlen] == '\0') /* found entry? */
|
||||
return(&a[middle]);
|
||||
/* adjust search params, try again. */
|
||||
else if (thispath[pathlen] > '/')
|
||||
hi = middle - 1;
|
||||
else
|
||||
hi = middle - 1; /* adjust search params, try again. */
|
||||
lo = middle + 1;
|
||||
} /* if */
|
||||
} /* while */
|
||||
|
||||
|
|
|
@ -245,9 +245,6 @@ static int wad_load_entries(const char *name, int forWriting, WADinfo *info)
|
|||
PHYSFS_uint32 fileCount;
|
||||
PHYSFS_uint32 directoryOffset;
|
||||
WADentry *entry;
|
||||
char lastDirectory[9];
|
||||
|
||||
lastDirectory[8] = 0; /* Make sure lastDirectory stays null-terminated. */
|
||||
|
||||
BAIL_IF_MACRO(!wad_open(name, forWriting, &fh, &fileCount,&directoryOffset), NULL, 0);
|
||||
info->entryCount = fileCount;
|
||||
|
|
|
@ -327,7 +327,8 @@ static int ZIP_seek(fvoid *opaque, PHYSFS_uint64 offset)
|
|||
return(0);
|
||||
|
||||
inflateEnd(&finfo->stream);
|
||||
memcpy(&finfo->stream, &str, sizeof (z_stream));
|
||||
inflateCopy(&finfo->stream, &str);
|
||||
inflateEnd(&str);
|
||||
finfo->uncompressed_position = finfo->compressed_position = 0;
|
||||
} /* if */
|
||||
|
||||
|
@ -375,7 +376,7 @@ static int ZIP_fileClose(fvoid *opaque)
|
|||
static PHYSFS_sint64 zip_find_end_of_central_dir(void *in, PHYSFS_sint64 *len)
|
||||
{
|
||||
PHYSFS_uint8 buf[256];
|
||||
PHYSFS_uint8 extra[4];
|
||||
PHYSFS_uint8 extra[4] = { 0, 0, 0, 0 };
|
||||
PHYSFS_sint32 i = 0;
|
||||
PHYSFS_sint64 filelen;
|
||||
PHYSFS_sint64 filepos;
|
||||
|
@ -384,8 +385,8 @@ static PHYSFS_sint64 zip_find_end_of_central_dir(void *in, PHYSFS_sint64 *len)
|
|||
int found = 0;
|
||||
|
||||
filelen = __PHYSFS_platformFileLength(in);
|
||||
BAIL_IF_MACRO(filelen == -1, NULL, 0); /* !!! FIXME: unlocalized string */
|
||||
BAIL_IF_MACRO(filelen > 0xFFFFFFFF, "ZIP bigger than 2 gigs?!", 0);
|
||||
BAIL_IF_MACRO(filelen == -1, NULL, -1); /* !!! FIXME: unlocalized string */
|
||||
BAIL_IF_MACRO(filelen > 0xFFFFFFFF, "ZIP bigger than 2 gigs?!", -1);
|
||||
|
||||
/*
|
||||
* Jump to the end of the file and start reading backwards.
|
||||
|
@ -535,6 +536,8 @@ static ZIPentry *zip_find_entry(ZIPinfo *info, const char *path, int *isDir)
|
|||
|
||||
else /* substring match...might be dir or entry or nothing. */
|
||||
{
|
||||
int i;
|
||||
|
||||
if (isDir != NULL)
|
||||
{
|
||||
*isDir = (thispath[pathlen] == '/');
|
||||
|
@ -544,9 +547,27 @@ static ZIPentry *zip_find_entry(ZIPinfo *info, const char *path, int *isDir)
|
|||
|
||||
if (thispath[pathlen] == '\0') /* found entry? */
|
||||
return(&a[middle]);
|
||||
else
|
||||
hi = middle - 1; /* adjust search params, try again. */
|
||||
} /* if */
|
||||
|
||||
/* substring match; search remaining space to find it... */
|
||||
for (i = lo; i < hi; i++)
|
||||
{
|
||||
thispath = a[i].name;
|
||||
if (strncmp(path, thispath, pathlen) == 0)
|
||||
{
|
||||
if (isDir != NULL)
|
||||
{
|
||||
*isDir = (thispath[pathlen] == '/');
|
||||
if (*isDir)
|
||||
return(NULL);
|
||||
} /* if */
|
||||
|
||||
if (thispath[pathlen] == '\0') /* found entry? */
|
||||
return(&a[i]);
|
||||
} /* if */
|
||||
} /* for */
|
||||
break;
|
||||
|
||||
} /* else */
|
||||
} /* while */
|
||||
|
||||
if (isDir != NULL)
|
||||
|
@ -625,6 +646,7 @@ static void zip_expand_symlink_path(char *path)
|
|||
else
|
||||
{
|
||||
prevptr = ptr;
|
||||
ptr++;
|
||||
} /* else */
|
||||
} /* while */
|
||||
} /* zip_expand_symlink_path */
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
#ifndef INCL_PHYSFSEXT_GLOBBING_H
|
||||
#define INCL_PHYSFSEXT_GLOBBING_H
|
||||
|
||||
/** \file globbing.h */
|
||||
|
||||
/**
|
||||
|
@ -30,6 +33,9 @@
|
|||
* \author Ryan C. Gordon.
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* \fn char **PHYSFS_enumerateFilesWildcard(const char *dir, const char *wildcard, int caseSensitive)
|
||||
|
@ -73,5 +79,11 @@ __EXPORT__ char **PHYSFSEXT_enumerateFilesWildcard(const char *dir,
|
|||
const char *wildcard,
|
||||
int caseSensitive);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* include-once blocker. */
|
||||
|
||||
/* end of globbing.h ... */
|
||||
|
||||
|
|
|
@ -98,7 +98,7 @@ int PHYSFSEXT_locateCorrectCase(char *buf)
|
|||
if (*ptr == '\0')
|
||||
return(0); /* Uh...I guess that's success. */
|
||||
|
||||
while (ptr = strchr(ptr + 1, '/'))
|
||||
while ( (ptr = strchr(ptr + 1, '/')) != NULL )
|
||||
{
|
||||
*ptr = '\0'; /* block this path section off */
|
||||
rc = locateOneElement(buf);
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
#ifndef INCL_PHYSFSEXT_IGNORECASE_H
|
||||
#define INCL_PHYSFSEXT_IGNORECASE_H
|
||||
|
||||
/** \file ignorecase.h */
|
||||
|
||||
/**
|
||||
|
@ -44,6 +47,9 @@
|
|||
* \author Ryan C. Gordon.
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* \fn int PHYSFSEXT_locateCorrectCase(char *buf)
|
||||
|
@ -71,5 +77,11 @@
|
|||
*/
|
||||
int PHYSFSEXT_locateCorrectCase(char *buf);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* include-once blocker. */
|
||||
|
||||
/* end of ignorecase.h ... */
|
||||
|
||||
|
|
|
@ -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"
|
||||
|
|
35
physfs.c
35
physfs.c
|
@ -43,7 +43,7 @@ typedef struct __PHYSFS_FILEHANDLE__
|
|||
|
||||
typedef struct __PHYSFS_ERRMSGTYPE__
|
||||
{
|
||||
PHYSFS_uint64 tid;
|
||||
void *tid;
|
||||
int errorAvailable;
|
||||
char errorString[80];
|
||||
struct __PHYSFS_ERRMSGTYPE__ *next;
|
||||
|
@ -94,7 +94,7 @@ static const PHYSFS_ArchiveInfo *supported_types[] =
|
|||
NULL
|
||||
};
|
||||
|
||||
static const PHYSFS_Archiver *archivers[] =
|
||||
static const PHYSFS_Archiver * const archivers[] =
|
||||
{
|
||||
&__PHYSFS_Archiver_DIR,
|
||||
#if (defined PHYSFS_SUPPORTS_ZIP)
|
||||
|
@ -261,14 +261,15 @@ void __PHYSFS_sort(void *entries, PHYSFS_uint32 max,
|
|||
* Quicksort w/ Bubblesort fallback algorithm inspired by code from here:
|
||||
* http://www.cs.ubc.ca/spider/harrison/Java/sorting-demo.html
|
||||
*/
|
||||
__PHYSFS_quick_sort(entries, 0, max - 1, cmpfn, swapfn);
|
||||
if (max > 0)
|
||||
__PHYSFS_quick_sort(entries, 0, max - 1, cmpfn, swapfn);
|
||||
} /* __PHYSFS_sort */
|
||||
|
||||
|
||||
static ErrMsg *findErrorForCurrentThread(void)
|
||||
{
|
||||
ErrMsg *i;
|
||||
PHYSFS_uint64 tid;
|
||||
void *tid;
|
||||
|
||||
if (errorLock != NULL)
|
||||
__PHYSFS_platformGrabMutex(errorLock);
|
||||
|
@ -416,7 +417,7 @@ static DirHandle *tryOpenDir(const PHYSFS_Archiver *funcs,
|
|||
static DirHandle *openDirectory(const char *d, int forWriting)
|
||||
{
|
||||
DirHandle *retval = NULL;
|
||||
const PHYSFS_Archiver **i;
|
||||
const PHYSFS_Archiver * const *i;
|
||||
const char *ext;
|
||||
|
||||
BAIL_IF_MACRO(!__PHYSFS_platformExists(d), ERR_NO_SUCH_FILE, NULL);
|
||||
|
@ -605,18 +606,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 +758,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);
|
||||
|
|
31
physfs.h
31
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 3
|
||||
#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].
|
||||
|
@ -994,8 +998,9 @@ __EXPORT__ const char *PHYSFS_getRealDir(const char *filename);
|
|||
* We've got [z.sav].
|
||||
* We've got [w.sav].\endverbatim
|
||||
*
|
||||
* Feel free to sort the list however you like. We only promise there will
|
||||
* be no duplicates, but not what order the final list will come back in.
|
||||
* Feel free to sort the list however you like. However, the returned data
|
||||
* will always contain no duplicates, and will be always sorted in alphabetic
|
||||
* (rather: Unicode) order for you.
|
||||
*
|
||||
* Don't forget to call PHYSFS_freeList() with the return value from this
|
||||
* function when you are done with it.
|
||||
|
@ -1211,9 +1216,9 @@ __EXPORT__ PHYSFS_sint64 PHYSFS_read(PHYSFS_File *handle,
|
|||
* The file must be opened for writing.
|
||||
*
|
||||
* \param handle retval from PHYSFS_openWrite() or PHYSFS_openAppend().
|
||||
* \param buffer buffer to store read data into.
|
||||
* \param objSize size in bytes of objects being read from (handle).
|
||||
* \param objCount number of (objSize) objects to read from (handle).
|
||||
* \param buffer buffer of bytes to write to (handle).
|
||||
* \param objSize size in bytes of objects being written to (handle).
|
||||
* \param objCount number of (objSize) objects to write to (handle).
|
||||
* \return number of objects written. PHYSFS_getLastError() can shed light on
|
||||
* the reason this might be < (objCount). -1 if complete failure.
|
||||
*/
|
||||
|
@ -2268,7 +2273,7 @@ __EXPORT__ void PHYSFS_enumerateFilesCallback(const char *dir,
|
|||
*
|
||||
* 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
|
||||
* 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 dst Buffer to store converted UTF-8 string.
|
||||
|
@ -2290,7 +2295,7 @@ __EXPORT__ void PHYSFS_utf8FromUcs4(const PHYSFS_uint32 *src, char *dst,
|
|||
*
|
||||
* 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
|
||||
* 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 dst Buffer to store converted UCS-4 string.
|
||||
|
@ -2313,7 +2318,7 @@ __EXPORT__ void PHYSFS_utf8ToUcs4(const char *src, PHYSFS_uint32 *dst,
|
|||
*
|
||||
* 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
|
||||
* 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"
|
||||
* values at this time.
|
||||
|
@ -2339,7 +2344,7 @@ __EXPORT__ void PHYSFS_utf8FromUcs2(const PHYSFS_uint16 *src, char *dst,
|
|||
*
|
||||
* 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
|
||||
* 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"
|
||||
* values at this time.
|
||||
|
@ -2365,7 +2370,7 @@ __EXPORT__ void PHYSFS_utf8ToUcs2(const char *src, PHYSFS_uint16 *dst,
|
|||
*
|
||||
* 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
|
||||
* 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
|
||||
* can't express most Unicode codepoints. It's a legacy encoding; you should
|
||||
|
|
|
@ -29,6 +29,10 @@
|
|||
#include <malloc.h>
|
||||
#endif
|
||||
|
||||
#if defined(__sun) || defined(sun)
|
||||
#include <alloca.h>
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
@ -966,7 +970,8 @@ char *__PHYSFS_convertToDependent(const char *prepend,
|
|||
#define PHYSFS_LIL_ENDIAN 1234
|
||||
#define PHYSFS_BIG_ENDIAN 4321
|
||||
|
||||
#if defined(__i386__) || defined(__ia64__) || defined(WIN32) || \
|
||||
#if defined(__i386__) || defined(__ia64__) || \
|
||||
defined(_M_IX86) || defined(_M_IA64) || defined(_M_X64) || \
|
||||
(defined(__alpha__) || defined(__alpha)) || \
|
||||
defined(__arm__) || defined(ARM) || \
|
||||
(defined(__mips__) && defined(__MIPSEL__)) || \
|
||||
|
@ -1221,8 +1226,7 @@ int __PHYSFS_platformSeek(void *opaque, PHYSFS_uint64 pos);
|
|||
*
|
||||
* Not all file types can "tell"; this is to be expected by the caller.
|
||||
*
|
||||
* On error, call __PHYSFS_setError() and return zero. On success, return
|
||||
* a non-zero value.
|
||||
* On error, call __PHYSFS_setError() and return -1. On success, return >= 0.
|
||||
*/
|
||||
PHYSFS_sint64 __PHYSFS_platformTell(void *opaque);
|
||||
|
||||
|
@ -1301,12 +1305,12 @@ char *__PHYSFS_platformGetUserName(void);
|
|||
char *__PHYSFS_platformGetUserDir(void);
|
||||
|
||||
/*
|
||||
* Return a number that uniquely identifies the current thread.
|
||||
* On a platform without threading, (1) will suffice. These numbers are
|
||||
* Return a pointer that uniquely identifies the current thread.
|
||||
* On a platform without threading, (0x1) will suffice. These numbers are
|
||||
* arbitrary; the only requirement is that no two threads have the same
|
||||
* number.
|
||||
* pointer.
|
||||
*/
|
||||
PHYSFS_uint64 __PHYSFS_platformGetThreadID(void);
|
||||
void *__PHYSFS_platformGetThreadID(void);
|
||||
|
||||
/*
|
||||
* Return non-zero if filename (in platform-dependent notation) exists.
|
||||
|
|
|
@ -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
|
||||
|
@ -38,7 +38,11 @@
|
|||
# endif
|
||||
#elif defined(macintosh)
|
||||
# error Classic Mac OS support was dropped from PhysicsFS 2.0. Move to OS X.
|
||||
#elif defined(unix)
|
||||
#elif defined(ANDROID)
|
||||
# define PHYSFS_PLATFORM_UNIX
|
||||
# define PHYSFS_PLATFORM_POSIX
|
||||
# define PHYSFS_NO_CDROM_SUPPORT
|
||||
#elif defined(unix) || defined(__unix__)
|
||||
# define PHYSFS_PLATFORM_UNIX
|
||||
# define PHYSFS_PLATFORM_POSIX
|
||||
#else
|
||||
|
|
|
@ -63,12 +63,13 @@ static PHYSFS_uint32 utf8codepoint(const char **_str)
|
|||
|
||||
else if (octet < 224) /* two octets */
|
||||
{
|
||||
(*_str)++; /* advance at least one byte in case of an error */
|
||||
octet -= (128+64);
|
||||
octet2 = (PHYSFS_uint32) ((PHYSFS_uint8) *(++str));
|
||||
if ((octet2 & (128+64)) != 128) /* Format isn't 10xxxxxx? */
|
||||
return UNICODE_BOGUS_CHAR_VALUE;
|
||||
|
||||
*_str += 2; /* skip to next possible start of codepoint. */
|
||||
*_str += 1; /* skip to next possible start of codepoint. */
|
||||
retval = ((octet << 6) | (octet2 - 128));
|
||||
if ((retval >= 0x80) && (retval <= 0x7FF))
|
||||
return retval;
|
||||
|
@ -76,6 +77,7 @@ static PHYSFS_uint32 utf8codepoint(const char **_str)
|
|||
|
||||
else if (octet < 240) /* three octets */
|
||||
{
|
||||
(*_str)++; // advance at least one byte in case of an error
|
||||
octet -= (128+64+32);
|
||||
octet2 = (PHYSFS_uint32) ((PHYSFS_uint8) *(++str));
|
||||
if ((octet2 & (128+64)) != 128) /* Format isn't 10xxxxxx? */
|
||||
|
@ -85,7 +87,7 @@ static PHYSFS_uint32 utf8codepoint(const char **_str)
|
|||
if ((octet3 & (128+64)) != 128) /* Format isn't 10xxxxxx? */
|
||||
return UNICODE_BOGUS_CHAR_VALUE;
|
||||
|
||||
*_str += 3; /* skip to next possible start of codepoint. */
|
||||
*_str += 2; /* skip to next possible start of codepoint. */
|
||||
retval = ( ((octet << 12)) | ((octet2-128) << 6) | ((octet3-128)) );
|
||||
|
||||
/* There are seven "UTF-16 surrogates" that are illegal in UTF-8. */
|
||||
|
@ -108,6 +110,7 @@ static PHYSFS_uint32 utf8codepoint(const char **_str)
|
|||
|
||||
else if (octet < 248) /* four octets */
|
||||
{
|
||||
(*_str)++; // advance at least one byte in case of an error
|
||||
octet -= (128+64+32+16);
|
||||
octet2 = (PHYSFS_uint32) ((PHYSFS_uint8) *(++str));
|
||||
if ((octet2 & (128+64)) != 128) /* Format isn't 10xxxxxx? */
|
||||
|
@ -121,7 +124,7 @@ static PHYSFS_uint32 utf8codepoint(const char **_str)
|
|||
if ((octet4 & (128+64)) != 128) /* Format isn't 10xxxxxx? */
|
||||
return UNICODE_BOGUS_CHAR_VALUE;
|
||||
|
||||
*_str += 4; /* skip to next possible start of codepoint. */
|
||||
*_str += 3; /* skip to next possible start of codepoint. */
|
||||
retval = ( ((octet << 18)) | ((octet2 - 128) << 12) |
|
||||
((octet3 - 128) << 6) | ((octet4 - 128)) );
|
||||
if ((retval >= 0x10000) && (retval <= 0x10FFFF))
|
||||
|
@ -136,6 +139,34 @@ static PHYSFS_uint32 utf8codepoint(const char **_str)
|
|||
|
||||
else if (octet < 252) /* five octets */
|
||||
{
|
||||
(*_str)++; // advance at least one byte in case of an error
|
||||
octet = (PHYSFS_uint32) ((PHYSFS_uint8) *(++str));
|
||||
if ((octet & (128+64)) != 128) /* Format isn't 10xxxxxx? */
|
||||
return UNICODE_BOGUS_CHAR_VALUE;
|
||||
|
||||
octet = (PHYSFS_uint32) ((PHYSFS_uint8) *(++str));
|
||||
if ((octet & (128+64)) != 128) /* Format isn't 10xxxxxx? */
|
||||
return UNICODE_BOGUS_CHAR_VALUE;
|
||||
|
||||
octet = (PHYSFS_uint32) ((PHYSFS_uint8) *(++str));
|
||||
if ((octet & (128+64)) != 128) /* Format isn't 10xxxxxx? */
|
||||
return UNICODE_BOGUS_CHAR_VALUE;
|
||||
|
||||
octet = (PHYSFS_uint32) ((PHYSFS_uint8) *(++str));
|
||||
if ((octet & (128+64)) != 128) /* Format isn't 10xxxxxx? */
|
||||
return UNICODE_BOGUS_CHAR_VALUE;
|
||||
|
||||
*_str += 4; /* skip to next possible start of codepoint. */
|
||||
return UNICODE_BOGUS_CHAR_VALUE;
|
||||
} /* else if */
|
||||
|
||||
else /* six octets */
|
||||
{
|
||||
(*_str)++; // advance at least one byte in case of an error
|
||||
octet = (PHYSFS_uint32) ((PHYSFS_uint8) *(++str));
|
||||
if ((octet & (128+64)) != 128) /* Format isn't 10xxxxxx? */
|
||||
return UNICODE_BOGUS_CHAR_VALUE;
|
||||
|
||||
octet = (PHYSFS_uint32) ((PHYSFS_uint8) *(++str));
|
||||
if ((octet & (128+64)) != 128) /* Format isn't 10xxxxxx? */
|
||||
return UNICODE_BOGUS_CHAR_VALUE;
|
||||
|
@ -156,32 +187,6 @@ static PHYSFS_uint32 utf8codepoint(const char **_str)
|
|||
return UNICODE_BOGUS_CHAR_VALUE;
|
||||
} /* else if */
|
||||
|
||||
else /* six octets */
|
||||
{
|
||||
octet = (PHYSFS_uint32) ((PHYSFS_uint8) *(++str));
|
||||
if ((octet & (128+64)) != 128) /* Format isn't 10xxxxxx? */
|
||||
return UNICODE_BOGUS_CHAR_VALUE;
|
||||
|
||||
octet = (PHYSFS_uint32) ((PHYSFS_uint8) *(++str));
|
||||
if ((octet & (128+64)) != 128) /* Format isn't 10xxxxxx? */
|
||||
return UNICODE_BOGUS_CHAR_VALUE;
|
||||
|
||||
octet = (PHYSFS_uint32) ((PHYSFS_uint8) *(++str));
|
||||
if ((octet & (128+64)) != 128) /* Format isn't 10xxxxxx? */
|
||||
return UNICODE_BOGUS_CHAR_VALUE;
|
||||
|
||||
octet = (PHYSFS_uint32) ((PHYSFS_uint8) *(++str));
|
||||
if ((octet & (128+64)) != 128) /* Format isn't 10xxxxxx? */
|
||||
return UNICODE_BOGUS_CHAR_VALUE;
|
||||
|
||||
octet = (PHYSFS_uint32) ((PHYSFS_uint8) *(++str));
|
||||
if ((octet & (128+64)) != 128) /* Format isn't 10xxxxxx? */
|
||||
return UNICODE_BOGUS_CHAR_VALUE;
|
||||
|
||||
*_str += 6; /* skip to next possible start of codepoint. */
|
||||
return UNICODE_BOGUS_CHAR_VALUE;
|
||||
} /* else if */
|
||||
|
||||
return UNICODE_BOGUS_CHAR_VALUE;
|
||||
} /* utf8codepoint */
|
||||
|
||||
|
@ -305,10 +310,11 @@ static void utf8fromcodepoint(PHYSFS_uint32 cp, char **_dst, PHYSFS_uint64 *_len
|
|||
} /* utf8fromcodepoint */
|
||||
|
||||
#define UTF8FROMTYPE(typ, src, dst, len) \
|
||||
if (len == 0) return; \
|
||||
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); \
|
||||
} \
|
||||
|
|
|
@ -174,14 +174,17 @@ static team_id getTeamID(void)
|
|||
|
||||
char *__PHYSFS_platformCalcBaseDir(const char *argv0)
|
||||
{
|
||||
/* in case there isn't a BApplication yet, we'll construct a roster. */
|
||||
BRoster roster;
|
||||
app_info info;
|
||||
status_t rc = roster.GetRunningAppInfo(getTeamID(), &info);
|
||||
BAIL_IF_MACRO(rc < B_OK, strerror(rc), NULL);
|
||||
BEntry entry(&(info.ref), true);
|
||||
image_info info;
|
||||
int32 cookie = 0;
|
||||
|
||||
while (get_next_image_info(0, &cookie, &info) == B_OK) {
|
||||
if (info.type == B_APP_IMAGE)
|
||||
break;
|
||||
}
|
||||
|
||||
BEntry entry(info.name, true);
|
||||
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);
|
||||
rc = path.GetParent(&path); /* chop filename, keep directory. */
|
||||
assert(rc == B_OK);
|
||||
|
@ -194,9 +197,9 @@ char *__PHYSFS_platformCalcBaseDir(const char *argv0)
|
|||
} /* __PHYSFS_platformCalcBaseDir */
|
||||
|
||||
|
||||
PHYSFS_uint64 __PHYSFS_platformGetThreadID(void)
|
||||
void *__PHYSFS_platformGetThreadID(void)
|
||||
{
|
||||
return((PHYSFS_uint64) find_thread(NULL));
|
||||
return((void *) find_thread(NULL));
|
||||
} /* __PHYSFS_platformGetThreadID */
|
||||
|
||||
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
#include <IOKit/storage/IOCDMedia.h>
|
||||
#include <IOKit/storage/IODVDMedia.h>
|
||||
#include <sys/mount.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
/* Seems to get defined in some system header... */
|
||||
#ifdef Free
|
||||
|
@ -28,11 +29,11 @@
|
|||
/* Wrap PHYSFS_Allocator in a CFAllocator... */
|
||||
static CFAllocatorRef cfallocator = NULL;
|
||||
|
||||
CFStringRef cfallocDesc(const void *info)
|
||||
CFStringRef cfallocCopyDesc(const void *info)
|
||||
{
|
||||
return(CFStringCreateWithCString(cfallocator, "PhysicsFS",
|
||||
kCFStringEncodingASCII));
|
||||
} /* cfallocDesc */
|
||||
} /* cfallocCopyDesc */
|
||||
|
||||
|
||||
static void *cfallocMalloc(CFIndex allocSize, CFOptionFlags hint, void *info)
|
||||
|
@ -61,7 +62,7 @@ int __PHYSFS_platformInit(void)
|
|||
/* set up a CFAllocator, so Carbon can use the physfs allocator, too. */
|
||||
CFAllocatorContext ctx;
|
||||
memset(&ctx, '\0', sizeof (ctx));
|
||||
ctx.copyDescription = cfallocDesc;
|
||||
ctx.copyDescription = cfallocCopyDesc;
|
||||
ctx.allocate = cfallocMalloc;
|
||||
ctx.reallocate = cfallocRealloc;
|
||||
ctx.deallocate = cfallocFree;
|
||||
|
@ -219,12 +220,15 @@ static char *convertCFString(CFStringRef cfstr)
|
|||
char *__PHYSFS_platformCalcBaseDir(const char *argv0)
|
||||
{
|
||||
ProcessSerialNumber psn = { 0, kCurrentProcess };
|
||||
struct stat statbuf;
|
||||
FSRef fsref;
|
||||
CFRange cfrange;
|
||||
CFURLRef cfurl = NULL;
|
||||
CFStringRef cfstr = NULL;
|
||||
CFMutableStringRef cfmutstr = NULL;
|
||||
char *retval = NULL;
|
||||
char *cstr = NULL;
|
||||
int rc = 0;
|
||||
|
||||
BAIL_IF_MACRO(GetProcessBundleLocation(&psn, &fsref) != noErr, NULL, NULL);
|
||||
cfurl = CFURLCreateFromFSRef(cfallocator, &fsref);
|
||||
|
@ -236,27 +240,46 @@ char *__PHYSFS_platformCalcBaseDir(const char *argv0)
|
|||
CFRelease(cfstr);
|
||||
BAIL_IF_MACRO(cfmutstr == NULL, NULL, NULL);
|
||||
|
||||
/* Find last dirsep so we can chop the binary's filename from the path. */
|
||||
cfrange = CFStringFind(cfmutstr, CFSTR("/"), kCFCompareBackwards);
|
||||
if (cfrange.location == kCFNotFound)
|
||||
/* we have to decide if we got a binary's path, or the .app dir... */
|
||||
cstr = convertCFString(cfmutstr);
|
||||
if (cstr == NULL)
|
||||
{
|
||||
assert(0); /* shouldn't ever hit this... */
|
||||
CFRelease(cfmutstr);
|
||||
return(NULL);
|
||||
} /* if */
|
||||
|
||||
/* chop the "/exename" from the end of the path string... */
|
||||
cfrange.length = CFStringGetLength(cfmutstr) - cfrange.location;
|
||||
CFStringDelete(cfmutstr, cfrange);
|
||||
rc = stat(cstr, &statbuf);
|
||||
allocator.Free(cstr); /* done with this. */
|
||||
if (rc == -1)
|
||||
{
|
||||
CFRelease(cfmutstr);
|
||||
return(NULL); /* maybe default behaviour will work? */
|
||||
} /* if */
|
||||
|
||||
/* If we're an Application Bundle, chop everything but the base. */
|
||||
cfrange = CFStringFind(cfmutstr, CFSTR("/Contents/MacOS"),
|
||||
kCFCompareCaseInsensitive |
|
||||
kCFCompareBackwards |
|
||||
kCFCompareAnchored);
|
||||
if (S_ISREG(statbuf.st_mode))
|
||||
{
|
||||
/* Find last dirsep so we can chop the filename from the path. */
|
||||
cfrange = CFStringFind(cfmutstr, CFSTR("/"), kCFCompareBackwards);
|
||||
if (cfrange.location == kCFNotFound)
|
||||
{
|
||||
assert(0); /* shouldn't ever hit this... */
|
||||
CFRelease(cfmutstr);
|
||||
return(NULL);
|
||||
} /* if */
|
||||
|
||||
if (cfrange.location != kCFNotFound)
|
||||
CFStringDelete(cfmutstr, cfrange); /* chop that, too. */
|
||||
/* chop the "/exename" from the end of the path string... */
|
||||
cfrange.length = CFStringGetLength(cfmutstr) - cfrange.location;
|
||||
CFStringDelete(cfmutstr, cfrange);
|
||||
|
||||
/* If we're an Application Bundle, chop everything but the base. */
|
||||
cfrange = CFStringFind(cfmutstr, CFSTR("/Contents/MacOS"),
|
||||
kCFCompareCaseInsensitive |
|
||||
kCFCompareBackwards |
|
||||
kCFCompareAnchored);
|
||||
|
||||
if (cfrange.location != kCFNotFound)
|
||||
CFStringDelete(cfmutstr, cfrange); /* chop that, too. */
|
||||
} /* if */
|
||||
|
||||
retval = convertCFString(cfmutstr);
|
||||
CFRelease(cfmutstr);
|
||||
|
@ -353,9 +376,9 @@ int __PHYSFS_platformSetDefaultAllocator(PHYSFS_Allocator *a)
|
|||
} /* __PHYSFS_platformSetDefaultAllocator */
|
||||
|
||||
|
||||
PHYSFS_uint64 __PHYSFS_platformGetThreadID(void)
|
||||
void *__PHYSFS_platformGetThreadID(void)
|
||||
{
|
||||
return( (PHYSFS_uint64) ((size_t) MPCurrentTaskID()) );
|
||||
return( (void *) ((size_t) MPCurrentTaskID()) );
|
||||
} /* __PHYSFS_platformGetThreadID */
|
||||
|
||||
|
||||
|
|
|
@ -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 */
|
||||
|
||||
|
||||
|
@ -649,7 +649,7 @@ PHYSFS_sint64 __PHYSFS_platformGetLastModTime(const char *fname)
|
|||
} /* __PHYSFS_platformGetLastModTime */
|
||||
|
||||
|
||||
PHYSFS_uint64 __PHYSFS_platformGetThreadID(void)
|
||||
void *__PHYSFS_platformGetThreadID(void)
|
||||
{
|
||||
PTIB ptib;
|
||||
PPIB ppib;
|
||||
|
@ -659,7 +659,7 @@ PHYSFS_uint64 __PHYSFS_platformGetThreadID(void)
|
|||
* default value (zero might as well do) if it does.
|
||||
*/
|
||||
BAIL_IF_MACRO(os2err(DosGetInfoBlocks(&ptib, &ppib)) != NO_ERROR, 0, 0);
|
||||
return((PHYSFS_uint64) ptib->tib_ordinal);
|
||||
return((void *) ptib->tib_ordinal);
|
||||
} /* __PHYSFS_platformGetThreadID */
|
||||
|
||||
|
||||
|
|
|
@ -161,9 +161,9 @@ char *__PHYSFS_platformGetUserDir(void)
|
|||
} /* __PHYSFS_platformGetUserDir */
|
||||
|
||||
|
||||
PHYSFS_uint64 __PHYSFS_platformGetThreadID(void)
|
||||
void *__PHYSFS_platformGetThreadID(void)
|
||||
{
|
||||
return(1); /* single threaded. */
|
||||
return((void *)1); /* single threaded. */
|
||||
} /* __PHYSFS_platformGetThreadID */
|
||||
|
||||
|
||||
|
@ -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);
|
||||
|
@ -467,7 +467,7 @@ PHYSFS_sint64 __PHYSFS_platformTell(void *opaque)
|
|||
LowPos = SetFilePointer(Handle, 0, &HighPos, FILE_CURRENT);
|
||||
if ((LowPos == INVALID_SET_FILE_POINTER) && (GetLastError() != NO_ERROR))
|
||||
{
|
||||
BAIL_MACRO(win32strerror(), 0);
|
||||
BAIL_MACRO(win32strerror(), -1);
|
||||
} /* if */
|
||||
else
|
||||
{
|
||||
|
@ -505,14 +505,18 @@ PHYSFS_sint64 __PHYSFS_platformFileLength(void *opaque)
|
|||
|
||||
int __PHYSFS_platformEOF(void *opaque)
|
||||
{
|
||||
const PHYSFS_sint64 FileLength = __PHYSFS_platformFileLength(opaque);
|
||||
PHYSFS_sint64 FilePosition;
|
||||
int retval = 0;
|
||||
|
||||
if (FileLength == 0)
|
||||
return 1; /* we're definitely at EOF. */
|
||||
|
||||
/* Get the current position in the file */
|
||||
if ((FilePosition = __PHYSFS_platformTell(opaque)) != 0)
|
||||
if ((FilePosition = __PHYSFS_platformTell(opaque)) != -1)
|
||||
{
|
||||
/* Non-zero if EOF is equal to the file length */
|
||||
retval = FilePosition == __PHYSFS_platformFileLength(opaque);
|
||||
retval = (FilePosition == FileLength);
|
||||
} /* if */
|
||||
|
||||
return(retval);
|
||||
|
|
|
@ -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 */
|
||||
|
||||
|
@ -370,14 +383,15 @@ int __PHYSFS_platformEOF(void *opaque)
|
|||
{
|
||||
PHYSFS_sint64 pos = __PHYSFS_platformTell(opaque);
|
||||
PHYSFS_sint64 len = __PHYSFS_platformFileLength(opaque);
|
||||
return(pos >= len);
|
||||
return((pos < 0) || (len < 0) || (pos >= len));
|
||||
} /* __PHYSFS_platformEOF */
|
||||
|
||||
|
||||
int __PHYSFS_platformFlush(void *opaque)
|
||||
{
|
||||
int fd = *((int *) opaque);
|
||||
BAIL_IF_MACRO(fsync(fd) == -1, strerror(errno), 0);
|
||||
if ((fcntl(fd, F_GETFL) & O_ACCMODE) != O_RDONLY)
|
||||
BAIL_IF_MACRO(fsync(fd) == -1, strerror(errno), 0);
|
||||
return(1);
|
||||
} /* __PHYSFS_platformFlush */
|
||||
|
||||
|
|
110
platform/unix.c
110
platform/unix.c
|
@ -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,9 +340,9 @@ 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_platformGetThreadID(void) { return((void *) 0x0001); }
|
||||
void *__PHYSFS_platformCreateMutex(void) { return((void *) 0x0001); }
|
||||
void __PHYSFS_platformDestroyMutex(void *mutex) {}
|
||||
int __PHYSFS_platformGrabMutex(void *mutex) { return(1); }
|
||||
|
@ -306,24 +357,9 @@ typedef struct
|
|||
PHYSFS_uint32 count;
|
||||
} PthreadMutex;
|
||||
|
||||
/* Just in case; this is a panic value. */
|
||||
#if ((!defined SIZEOF_INT) || (SIZEOF_INT <= 0))
|
||||
# define SIZEOF_INT 4
|
||||
#endif
|
||||
|
||||
#if (SIZEOF_INT == 4)
|
||||
# define PHTREAD_TO_UI64(thr) ( (PHYSFS_uint64) ((PHYSFS_uint32) (thr)) )
|
||||
#elif (SIZEOF_INT == 2)
|
||||
# define PHTREAD_TO_UI64(thr) ( (PHYSFS_uint64) ((PHYSFS_uint16) (thr)) )
|
||||
#elif (SIZEOF_INT == 1)
|
||||
# define PHTREAD_TO_UI64(thr) ( (PHYSFS_uint64) ((PHYSFS_uint8) (thr)) )
|
||||
#else
|
||||
# define PHTREAD_TO_UI64(thr) ((PHYSFS_uint64) (thr))
|
||||
#endif
|
||||
|
||||
PHYSFS_uint64 __PHYSFS_platformGetThreadID(void)
|
||||
void *__PHYSFS_platformGetThreadID(void)
|
||||
{
|
||||
return(PHTREAD_TO_UI64(pthread_self()));
|
||||
return( (void *) ((size_t) pthread_self()) );
|
||||
} /* __PHYSFS_platformGetThreadID */
|
||||
|
||||
|
||||
|
@ -387,7 +423,7 @@ void __PHYSFS_platformReleaseMutex(void *mutex)
|
|||
} /* if */
|
||||
} /* __PHYSFS_platformReleaseMutex */
|
||||
|
||||
#endif /* !PHYSFS_NO_PTHREADS_SUPPORT */
|
||||
#endif /* !PHYSFS_NO_THREAD_SUPPORT */
|
||||
|
||||
#endif /* PHYSFS_PLATFORM_UNIX */
|
||||
|
||||
|
|
|
@ -451,7 +451,6 @@ static int determineUserDir(void)
|
|||
if (OpenProcessToken(processHandle, TOKEN_QUERY, &accessToken))
|
||||
{
|
||||
DWORD psize = 0;
|
||||
WCHAR dummy = 0;
|
||||
LPWSTR wstr = NULL;
|
||||
BOOL rc = 0;
|
||||
|
||||
|
@ -460,8 +459,9 @@ static int determineUserDir(void)
|
|||
* psize. Also note that the second parameter can't be
|
||||
* NULL or the function fails.
|
||||
*/
|
||||
rc = pGetUserProfileDirectoryW(accessToken, &dummy, &psize);
|
||||
rc = pGetUserProfileDirectoryW(accessToken, NULL, &psize);
|
||||
assert(!rc); /* !!! FIXME: handle this gracefully. */
|
||||
(void)rc;
|
||||
|
||||
/* Allocate memory for the profile directory */
|
||||
wstr = (LPWSTR) __PHYSFS_smallAlloc(psize * sizeof (WCHAR));
|
||||
|
@ -559,9 +559,9 @@ char *__PHYSFS_platformGetUserDir(void)
|
|||
} /* __PHYSFS_platformGetUserDir */
|
||||
|
||||
|
||||
PHYSFS_uint64 __PHYSFS_platformGetThreadID(void)
|
||||
void *__PHYSFS_platformGetThreadID(void)
|
||||
{
|
||||
return((PHYSFS_uint64) GetCurrentThreadId());
|
||||
return( (void *) ((size_t) GetCurrentThreadId()) );
|
||||
} /* __PHYSFS_platformGetThreadID */
|
||||
|
||||
|
||||
|
@ -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
|
||||
|
@ -1142,7 +1142,7 @@ PHYSFS_sint64 __PHYSFS_platformTell(void *opaque)
|
|||
if ( (LowPos == PHYSFS_INVALID_SET_FILE_POINTER) &&
|
||||
(GetLastError() != NO_ERROR) )
|
||||
{
|
||||
BAIL_MACRO(winApiStrError(), 0);
|
||||
BAIL_MACRO(winApiStrError(), -1);
|
||||
} /* if */
|
||||
else
|
||||
{
|
||||
|
@ -1181,14 +1181,18 @@ PHYSFS_sint64 __PHYSFS_platformFileLength(void *opaque)
|
|||
|
||||
int __PHYSFS_platformEOF(void *opaque)
|
||||
{
|
||||
const PHYSFS_sint64 FileLength = __PHYSFS_platformFileLength(opaque);
|
||||
PHYSFS_sint64 FilePosition;
|
||||
int retval = 0;
|
||||
|
||||
if (FileLength == 0)
|
||||
return 1; /* we're definitely at EOF. */
|
||||
|
||||
/* Get the current position in the file */
|
||||
if ((FilePosition = __PHYSFS_platformTell(opaque)) != 0)
|
||||
if ((FilePosition = __PHYSFS_platformTell(opaque)) != -1)
|
||||
{
|
||||
/* Non-zero if EOF is equal to the file length */
|
||||
retval = FilePosition == __PHYSFS_platformFileLength(opaque);
|
||||
retval = (FilePosition == FileLength);
|
||||
} /* if */
|
||||
|
||||
return(retval);
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
|
||||
#define TEST_VERSION_MAJOR 2
|
||||
#define TEST_VERSION_MINOR 0
|
||||
#define TEST_VERSION_PATCH 0
|
||||
#define TEST_VERSION_PATCH 3
|
||||
|
||||
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 3
|
||||
|
||||
//static PHYSFS_uint32 do_buffer_size = 0;
|
||||
|
||||
|
|
Loading…
Reference in New Issue