PhysicsFS; a portable, flexible file i/o abstraction. https://icculus.org/physfs/ Please see the docs directory for documentation. Please see LICENSE.txt for licensing information.
PhysicsFS; a portable, flexible file i/o abstraction.
Overview
Issues
-
-Wint-in-bool-context warning
From CI run logs:
In file included from /home/runner/work/physfs/physfs/src/physfs.c:12: /home/runner/work/physfs/physfs/src/physfs.c: In function ‘openDirectory’: /home/runner/work/physfs/physfs/src/physfs.c:929:40: warning: ?: using integer constants in boolean context [-Wint-in-bool-context] 929 | BAIL_IF(!retval, claimed ? errcode : PHYSFS_ERR_UNSUPPORTED, NULL); | ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~ /home/runner/work/physfs/physfs/src/physfs_internal.h:273:44: note: in definition of macro ‘BAIL_IF’ 273 | #define BAIL_IF(c, e, r) do { if (c) { if (e) PHYSFS_setErrorCode(e); return r; } } while (0) | ^
Is the following correct??
diff --git a/src/physfs.c b/src/physfs.c index e7ceddd..568f1fc 100644 --- a/src/physfs.c +++ b/src/physfs.c @@ -921,12 +921,12 @@ static DirHandle *openDirectory(PHYSFS_Io *io, const char *d, int forWriting) retval = tryOpenDir(io, *i, d, forWriting, &claimed); } /* else */ - errcode = currentErrorCode(); + errcode = claimed ? currentErrorCode() : PHYSFS_ERR_UNSUPPORTED; if ((!retval) && (created_io)) io->destroy(io); - BAIL_IF(!retval, claimed ? errcode : PHYSFS_ERR_UNSUPPORTED, NULL); + BAIL_IF(!retval, errcode, NULL); return retval; } /* openDirectory */
-
Fix UTF-16 to UTF-8 conversion
Converting UTF-16 surrogate pairs to temporary UTF-32 codepoints is missing the 0x10000 bit, which causes failure when enumerating directories containing particular unicode filenames on Windows.
-
CMake: Use target_include_directories()
The CMake build currently uses
include_directories()
to add thesrc
directory to the includes. It would be better to usetarget_include_directories()
to have the target include the actual directory rather than in the global cmake space.https://cmake.org/cmake/help/latest/command/target_include_directories.html
option(PHYSFS_BUILD_STATIC "Build static library" TRUE) if(PHYSFS_BUILD_STATIC) add_library(physfs-static STATIC ${PHYSFS_SRCS}) target_include_directories(physfs-static PUBLIC src)
-
Problem with root directories
I'm calling PHYSFS_stat() on a directory contained in the root, and with a single ZIP mounted and a "root directory" set to "data"
In function verifyPath(), the "prepend the root directory, if any" section, fname[] is being set to "dat/dir" rather than "data/dir". The issue seems to be an off-by-one, when prepending the root directory.
Old code:
if (h->root) { const int isempty = (*fname == '\0'); fname -= h->rootlen - 1; strcpy(fname, h->root); if (!isempty) fname[h->rootlen - 2] = '/'; *_fname = fname; } /* if */
Modified code:
if (h->root) { const int isempty = (*fname == '\0'); fname -= h->rootlen; strcpy(fname, h->root); if (!isempty) fname[h->rootlen - 1] = '/'; *_fname = fname; } /* if */
This seems to fix the problem, but I'm not sure if it could introduce problems elsewhere.
-
cmake: bump minimum cmake version to 3.0 + add target_include_directories
- Bumping CMake minimum version to 3.0 gets rid of these warnings:
CMake Deprecation Warning at CMakeLists.txt:12 (cmake_minimum_required): Compatibility with CMake < 2.8.12 will be removed from a future version of CMake. Update the VERSION argument <min> value or use a ...<max> suffix to tell CMake that the project does not need compatibility with older versions.
and
CMake Warning (dev) at CMakeLists.txt:15 (project): Policy CMP0048 is not set: project() command manages VERSION variables. Run "cmake --help-policy CMP0048" for policy details. Use the cmake_policy command to set the policy and suppress this warning. The following variable(s) would be set to empty: CMAKE_PROJECT_VERSION CMAKE_PROJECT_VERSION_MAJOR CMAKE_PROJECT_VERSION_MINOR CMAKE_PROJECT_VERSION_PATCH This warning is for project developers. Use -Wno-dev to suppress it.
- use
list(APPEND)
where applicable. - use
WIN32
. Also, the comment "we're about to move to Win64" is outdated. - conditionally enable c++
- Create
PhysFS::PhysFS
andPhysFS::PhysFS-static
targets, and export those via the installed cmake packages. - Use
target_include_directories(tgt PUBLIC "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}")
This fixes https://github.com/icculus/physfs/issues/14 (You need to use a generator expression because you don't want to make build machine paths to appear in the exported cmake package)
Fixes https://github.com/icculus/physfs/issues/14
- Bumping CMake minimum version to 3.0 gets rid of these warnings:
-
Android APK support
This bug report was migrated from our old Bugzilla tracker.
These attachments are available in the static archive:
- Simple Android.mk file. Enables ZIP and APK support. (Android.mk, text/x-makefile, 2014-04-27 18:48:46 -0400, 585 bytes)
- Patch with the implementation and the required changes for src/physfs.c and the CMake build script (physfs_apk_support.patch, text/plain, 2014-04-27 18:50:33 -0400, 4951 bytes)
Reported in version: all Reported for operating system, platform: other, Other
Comments on the original bug report:
On 2014-04-27 18:48:46 -0400, rettichschnidi wrote:
Created attachment 3439 Simple Android.mk file. Enables ZIP and APK support.
Based on the archiver_zip.c file I created a super simple hack which allows to use physfs to mount an Android APK file.
It basicly just prexfixes each filename with "/assets/" and then forwards the real work to the ZIP implementation in archiver_zip.c.
There is also a simple Android.mk file which is configured to enable ZIP and APK support.
On 2014-04-27 18:50:33 -0400, rettichschnidi wrote:
Created attachment 3440 Patch with the implementation and the required changes for src/physfs.c and the CMake build script
-
Update LZMA archiver to latest LZMA SDK
This bug report was migrated from our old Bugzilla tracker.
These attachments are available in the static archive:
Reported in version: all Reported for operating system, platform: All, PC
Comments on the original bug report:
On 2015-01-10 09:39:41 -0500, Jan Hellwig wrote:
Created attachment 3508 Patch to update the LZMA SDK and LZMA archiver
Currently PhysicsFS uses an old version of the LZMA SDK. Since then the SDK has been updates with bugfixes, new features, etc. Also the license of the LZMA SDK was placed in the public domain (was LGPL before). As the API has changed quite a bit over the years the PhysicsFS LZMA archiver also needed to be update to work with the new LZMA SDK API.
I attached a patch file that does update the LZMA SDK as well as the LZMA archiver to the latest version. If you prefer to use the latest stable LZMA SDK (9.20, 4 years old), I do have a patch for that as well.
-
PHYSFS_platformGrabMutex causes EXC_BAD_INSTRUCTION in iOS 10 simulator
This bug report was migrated from our old Bugzilla tracker.
These attachments are available in the static archive:
Reported in version: all Reported for operating system, platform: MacOS X, Macintosh
Comments on the original bug report:
On 2017-04-19 17:27:15 -0400, Tyler Funk wrote:
Created attachment 3579 Copied error dump from XCode
This issue is occurring when attempting to run LÃVE 2D on the iOS simulator. I posted in their forums, and they were convinced it was a PhysicsFS issue, not a LÃVE issue.
I am using the physfs.framework provided in the love-osx-frameworks-0.10.zip download located here: https://love2d.org/sdk/
If you have questions or need more information, please let me know. The crash does not provide much of a stack trace but I'll do what I can.
LÃVE version: 0.10.1 XCode version: 8.3.2 (8E2002) iOS Simulator version: 10.0 iOS Simulation: iPhone 6s - iOS 10.3 (14E269)
-
Build fails due to -Werror
This bug report was migrated from our old Bugzilla tracker.
Reported in version: all Reported for operating system, platform: Windows NT, PC
Comments on the original bug report:
On 2015-02-07 07:44:17 -0500, Aleksi Juvani wrote:
2.0.3 build fails on 64-bit Windows 8 with MinGW and GCC 4.8.0 with the following errors:
physfs-2.0.3/archivers/lzma.c: In function 'SzFileReadImp': physfs-2.0.3/archivers/lzma.c:133:46: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast] FileInputStream *s = (FileInputStream *)((unsigned long)object - offsetof(FileInputStream, inStream)); /* HACK! */ ^ physfs-2.0.3/archivers/lzma.c: In function 'SzFileSeekImp': physfs-2.0.3/archivers/lzma.c:148:46: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast] FileInputStream *s = (FileInputStream *)((unsigned long)object - offsetof(FileInputStream, inStream)); /* HACK! */ ^ cc1.exe: all warnings being treated as errors
The development branch from the repository fails to build with the following errors:
physfs/src/platform_windows.c: In function '__PHYSFS_platformEnumerateFiles': physfs/src/platform_windows.c:533:21: error: unused variable 'tag' [Werror=unused-variable] const DWORD tag = entw.dwReserved0; ^ physfs/src/platform_windows.c:532:21: error: unused variable 'attr' [Werror=unused-variable] const DWORD attr = entw.dwFileAttributes; ^ physfs/src/platform_windows.c: At top level: physfs/src/platform_windows.c:483:12: error: 'isSymlinkAttrs' defined but not used [-Werror=unused-function] static int isSymlinkAttrs(const DWORD attr, const DWORD tag) ^ cc1.exe: all warnings being treated as errors
Both build fine if I manually remove the -Werror flag from CMakeLists.txt. I'd recommend removing -Werror by default. It makes sense for development, but not as a default for every build.
On 2015-05-03 01:30:40 -0400, Bradley Bell wrote:
cast to unsigned long seems pretty unnecessary there.
diff -r aaa1204a4426 archivers/lzma.c --- a/archivers/lzma.c Thu Aug 14 21:27:00 2014 -0400 +++ b/archivers/lzma.c Sat May 02 22:20:44 2015 -0700 @@ -130,7 +130,7 @@ 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 *)(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 SzFileSeekImp(void *object, CFileSize pos) { - FileInputStream *s = (FileInputStream *)((unsigned long)object - offsetof(FileInputStream, inStream)); /* HACK! */ + FileInputStream *s = (FileInputStream *)(object - offsetof(FileInputStream, inStream)); /* HACK! */ if (__PHYSFS_platformSeek(s->file, (PHYSFS_uint64) pos)) return SZ_OK; return SZE_FAIL;
-
64 bit division on a 32 bit system fails to link
This bug report was migrated from our old Bugzilla tracker.
Reported in version: all Reported for operating system, platform: All, PC
Comments on the original bug report:
On 2013-06-04 01:27:59 -0400, [email protected] wrote:
When compiling physicsfs with gcc on a 32bit Linux or OSX system, the library fails to link with the following error:
undefined reference to `__divdi3'
This is because of the 64 bit division in PHYSFS_read() and PHYSFS_write() with the line:
return ( (retval <= 0) ? retval : (retval / ((PHYSFS_sint64) size)) );
I found some similar discussion on the topic here:
http://stackoverflow.com/questions/35463/how-to-divide-two-64-bit-numbers-in-linux-kernel
Thanks for any help
On 2013-06-04 10:08:36 -0400, [email protected] wrote:
I forgot to add that this occurs with static linking
On 2013-12-05 15:50:23 -0500, Matthias Mailänder wrote:
I think http://software.opensuse.org/package/libphysfs1 are also effected by this. It does not work at all for me on i586 (tried Blobby Volley 2 and Hedgewars).
-
Fix physfsrwops_write
This bug report was migrated from our old Bugzilla tracker.
These attachments are available in the static archive:
Reported in version: all Reported for operating system, platform: All, All
Comments on the original bug report:
On 2015-07-30 20:34:32 -0400, rettichschnidi wrote:
Created attachment 3544 Patch against tip
physfsrwops_write does not return what is specified in the documentation of SDL's read function in SDL_RWops.
On 2015-07-30 20:38:05 -0400, rettichschnidi wrote:
/read function/write function/
-
[Bug] Stack Pointer Leak Out-Of-Scope
While porting physfs to be usable on Wii U homebrew, it was discovered this leaks a stack pointer out of scope.
We found this because
PHYSFS_exists
was failing, so the parameters ofcreateDirHandle
were logged:00;41;58;987: mountPoint pêÀT¸T/ 00;41;58;987: dirName fs:/vol/external01/save/game
We have patched this to make the minimum for smallAlloc be zero to avoid this issue. Hopefully this is a trivial fix.
-
PhysicsFS 4.0 plans...
This is preliminary, but here's some initial wishlist things I'd like to do:
- Make the Android stuff not use PHYSFS_Init with a magic structure. This was a wrong move.
- Move all the global state into a struct and let people create instances, each with their own search path, write dir, mutexes, etc. All the functions will take an instance pointer; for people that don't care about this or want to build legacy code, we'll leave the original entry points alone, and those will manage an internal instance (or write a physfs3-compat library).
- Remove CD-ROM support (entry point will remain but never find any discs).
- Multiple write directories; they'll interpolate and mount and such like the search path does.
- Queries for other writeable directories (config/cache/etc), instead of just a "pref path"
- Probably other things.
-
archive_iso9660 has wrong ISO9660FileFlags struct size when built using MSVC
This bug report was migrated from our old Bugzilla tracker.
These attachments are available in the static archive:
Reported in version: all Reported for operating system, platform: Windows Vista, PC
Comments on the original bug report:
On 2015-04-10 12:34:56 -0400, Jonathan Hamilton wrote:
Created attachment 3532 Fix ISO9660FileFlags struct size on msvc
MSVC (at least version 13 - 'VS Express 2013 for Desktop') appear to expect the minimum size of packed bitfields to be specified. This means using 'unsigned' causes the size of the flags field to be 4 bytes (instead of the expected one).
This then causes the sizeof() the various record structs to be incorrect, causing them to be incorrectly read from the file.
Tested on windows 7 and windows 8.1 built with 'VS Express 2013 for Desktop'
-
archive_iso9660 rejects valid files due to broken error checking
This bug report was migrated from our old Bugzilla tracker.
These attachments are available in the static archive:
- Fix read error checking (physfs-iso9660-fix-read-error-checking.diff, text/plain, 2015-04-10 12:28:41 -0400, 1293 bytes)
- Fix magic memcmp length (physfs-iso9660-compare-5-bytes-of-magic.diff, text/plain, 2015-04-10 12:29:13 -0400, 841 bytes)
Reported in version: all Reported for operating system, platform: Linux, PC
Comments on the original bug report:
On 2015-04-10 12:28:41 -0400, Jonathan Hamilton wrote:
Created attachment 3530 Fix read error checking
As far as I can see, iso_readimage() and io->read() return the number of bytes read, but this seems wrong in a couple of places:
- Reading 5 bytes of the magic number appears to expect io->read() to return 'Not 5'. This value is then checked with a memcmp of 6 bytes, comparing 1-over the array.
- Reading the file descriptor appears to expect iso_readimage to return '1' on success, however it actually returns the number of bytes read.
Patches should be attached.
Thanks, Jonathan
On 2015-04-10 12:29:13 -0400, Jonathan Hamilton wrote:
Created attachment 3531 Fix magic memcmp length
-
Feature/change: enable writing to multiple separate directories via mount-for-write
I contribute to the LÖVE game framework, which uses PhysFS, and a common user complaint has been that while the write-to-single-common-directory paradigm works OK for most games, it's too limited for things like tools and non-standard games or other apps that need to interact with the filesystem in more arbitrary manners.
Another related issue is that many operating systems (e.g. macOS, iOS, Windows) really want apps to use different common data locations for slightly different purposes. For example on iOS, files saved to
Documents
andApplication Support
may be automatically cloud-synced whereas files saved totmp
andCaches
will not be. AndDocuments
is meant for user-visible content (e.g. screenshots) whereasApplication Support
is not (e.g. a progress save file). Since iOS has restrictive sandboxing, I don't believe setting/
as the write directory works.In my opinion having to change the write directory - and having to make sure all open-for-write files are closed before doing so - each time a file is written to a different one of those locations is much too cumbersome and limiting, and doesn't fit with PhysFS' other virtual filesystem APIs.
To lift those limitations in LÖVE, I forked PhysFS and added a new
PHYSFS_mountRW
function which is just likePHYSFS_mount
but with some internals changed to allow writing to the given location. Since write access tends to be allowed in fewer locations than read access, having a separate function fromPHYSFS_mount
still makes a lot of sense to me (although I suppose an enum or boolean parameter would work too, but it would also be a breaking change).Here is my branch with the change: https://github.com/icculus/physfs/compare/main...slime73:mountRW It's been tested but not by a ton of people yet, and I don't have a ton of experience with PhysFS' codebase so there might be bugs.
My questions are: is the overall idea within the scope of what you want PhysFS to be, and if so is my API reasonable? If yes I can open a pull request. I don't mind maintaining a fork but I'd prefer having the idea upstreamed.
-
From dosbox-x : use overlay file when its newer than zips
Hi!
A very discrete problem: i have a zip of an dos game. This is mounted via dosboxx via physfs overlay. In this archive there is an file "sndcfg.ini". I need to replace this file while using the overlay. This is not possible. This the old file from the archive is used, although there is the new sndcfg.ini in the overlay part.
wish: in doubt use the overlays file (when its newer etc)
marco
Owner
Ryan C. Gordon
convert elf file to single c/c++ header file
elf-to-c-header Split ELF to single C/C++ header file
libcurses and dependencies taken from netbsd and brought into a portable shape (at least to musl or glibc)
netbsd-libcurses portable edition this is a port of netbsd's curses library for usage on Linux systems (tested and developed on sabotage linux, based
Internet Key Exchange version 2 (IKEv2) daemon - portable version of OpenBSD iked
Portable OpenIKED This is a port of OpenBSD's OpenIKED to different Unix-like operating systems, including Linux, macOS and FreeBSD.
Locate the current executable and the current module/library on the file system
Where Am I? A drop-in two files library to locate the current executable and the current module on the file system. Supported platforms: Windows Linux
Simple .INI file parser in C, good for embedded systems
inih (INI Not Invented Here) inih (INI Not Invented Here) is a simple .INI file parser written in C. It's only a couple of pages of code, and it was d
ini file parser
Iniparser 4 I - Overview This modules offers parsing of ini files from the C level. See a complete documentation in HTML format, from this directory o
Small configuration file parser library for C.
libConfuse Introduction Documentation Examples Build & Install Origin & References Introduction libConfuse is a configuration file parser library writ
Beacon Object File (BOF) for remote process injection via thread hijacking
cThreadHijack ___________.__ .______ ___ .__ __ __ ___\__ ___/| |_________ ____ _____
A Cobalt Strike Beacon Object File (BOF) project which uses direct system calls to enumerate processes for specific loaded modules or process handles.
FindObjects-BOF A Cobalt Strike Beacon Object File (BOF) project which uses direct system calls to enumerate processes for specific modules or process
A Beacon Object File (BOF) for Cobalt Strike which uses direct system calls to enable WDigest credential caching.
WdToggle A Proof of Concept Cobalt Strike Beacon Object File which uses direct system calls to enable WDigest credential caching and circumvent Creden
Dead simple C logging library contained in a single header (.h) file
Seethe Logging so simple, you only need to include a single header file. seethe supports 6 different log levels (DEBUG, INFO, NOTICE, WARNING, ERROR,
Example of transferring file data over BLE using an Arduino Nano Sense and WebBLE
BLE File Transfer Example of transferring file data over BLE to an Arduino Nano Sense using WebBLE. Overview This is an example of how to use Bluetoot
featured cs:go internal hack, one file and less than 1000 lines.
singlefile This is a featured CS:GO internal cheat written in less than 1000 lines, and in one C++ file. I encourage you to submit feature suggestions
C++ NIF library for the Gamebryo/NetImmerse File Format
nifly C++ NIF library for the Gamebryo/NetImmerse File Format. Created with a clean-room design. Features Reading and writing NIF files (Gamebryo/NetI
An asynchronous directory file change watcher module for Windows, macOS and Linux wrapped for V
A V module for asynchronously watching for file changes in a directory. The module is essentially a wrapper for septag/dmon. It works for Windows, macOS and Linux.
mpiFileUtils - File utilities designed for scalability and performance.
mpiFileUtils provides both a library called libmfu and a suite of MPI-based tools to manage large datasets, which may vary from large directory trees to large files.
Simple and lightweight pathname parser for C. This module helps to parse dirname, basename, filename and file extension .
Path Module For C File name and extension parsing functionality are removed because it's difficult to distinguish between a hidden dir (ex: .git) and
A PE parser written as an exercise to study the PE file structure.
Description A PE parser written as an exercise to study the PE file structure. It parses the following parts of PE32 and PE32+ files: DOS Header Rich
A linux library to get the file path of the currently running shared library. Emulates use of Win32 GetModuleHandleEx/GetModuleFilename.
whereami A linux library to get the file path of the currently running shared library. Emulates use of Win32 GetModuleHandleEx/GetModuleFilename. usag