Commit Graph

143 Commits

Author SHA1 Message Date
Ryan C. Gordon 4d9bcc3d1a
atomic: __PHYSFS_ATOMIC_(DECR|INCR) should return final value.
Fixes #46.
2022-09-29 10:53:18 -04:00
Ryan C. Gordon 496817a9e8
PHYSFS_mkdir() should allow symlinks in the mounted writeDir itself.
Fixes #47.
2022-09-29 10:27:23 -04:00
Ozkan Sezer fb0901b10f silence a -Wint-in-bool-context warning:
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)
      |                                            ^

Closes https://github.com/icculus/physfs/issues/44
2022-06-15 20:56:28 +03:00
Ryan C. Gordon 48e7c2e3af
root: Fix string handling of paths from PHYSFS_setRoot.
Fixes #4.
2022-05-20 22:06:33 -04:00
Ryan C. Gordon 497934818b
Fixed memory leak when closing a DirHandle with a root (thanks, jajiradai!).
Fixes #3.
2022-05-20 21:27:46 -04:00
Ryan C. Gordon 17b691b0ea
Let several archives be case-insensitive.
(and several more probably _should_ be but I don't have the details on
them at the moment. But now it's just changing a 1 to a 0 to fix those!)
2022-05-20 17:36:06 -04:00
Ryan C. Gordon 5ea6ba7557 msvc: Move stdarg.h include ahead of __PHYSFS_msvc_vsnprintf declaration. 2021-04-29 15:00:16 -04:00
Ryan C. Gordon 55c3d9f9d8 android: PhysicsFS now has actual Android support.
This compiled and worked on Android before, if you didn't care about
PHYSFS_getBaseDir() and PHYSFS_getPrefDir() being useful. Now you can pass
PHYSFS_init() some necessary Android objects to solve this. Passing NULL
to PHYSFS_init is acceptable and will simply report "/" for the base dir and
prefdir, under the assumption that the app queried the OS for these directly
instead.
2020-06-12 03:37:58 -04:00
Ryan C. Gordon 235e31c420 Fixed mishandling of an allocation failure in PHYSFS_openRead().
(Static analysis caught this one! Thanks clang!)
2020-05-12 15:19:01 -04:00
Ryan C. Gordon 5cbb460bcd Only flush file handles on close if they were opened for writing. 2019-03-18 11:27:26 -04:00
Ryan C. Gordon b57d8960e8 Fixed some compiler warnings. 2018-11-28 00:23:08 -05:00
Ryan C. Gordon 5786a58628 PHYSFS_flush() shouldn't call PHYSFS_Io::flush().
The former is meant to send PhysicsFS-buffered data to the PHYSFS_Io's
implementation, the latter is meant to tell the OS to definitely make sure the
data is safely written to disk (or at least, that's what it does in practice).

This was making PHYSFS_setBuffer()'d handles _slower_, since they would end
up blocking whenever the buffer was full until the data made the full trip to
physical media, instead of just letting the OS do its own buffering.

Now we still PHYSFS_Io::flush() on PHYSFS_close(), like this has always
worked. That might also be overkill, but that remains a historical artifact
of trying to keep the underlying file handle usable if pending writes fail
for possibly-recoverable reasons (which isn't guaranteed if you just close()
it, at least as far as I remember).
2018-11-27 23:53:33 -05:00
Ryan C. Gordon 73d66441e3 Added PHYSFS_setRoot(). 2018-10-17 23:44:02 -04:00
Ryan C. Gordon 8ce294a458 PHYSFS_setWriteDir() shouldn't create an empty file if the dir doesn't exist. 2018-05-16 19:54:51 -04:00
Ryan C. Gordon a45afc5d50 Catch access to paths that are just "." or ".." without any path separator. 2017-10-26 14:37:16 -04:00
Ryan C. Gordon 62d24e228f Fixed mounting a symlink to a real directory. 2017-10-26 14:21:36 -04:00
Ryan C. Gordon 1c7945461d Don't allow NULL filenames to be mounted.
Regardless of what the 3.0.0 documentation says, PhysicsFS never handled this
correctly, so now we check for it so you can't get into crashy situations.

Corrected documentation to reflect reality.
2017-10-23 12:40:59 -04:00
Ryan C. Gordon 3d8817346d Fixed seeking within read buffers. 2017-09-25 16:32:52 -04:00
Ryan C. Gordon 425131ccda Simplified doBufferedRead().
No longer recurses, and deals with EOF correctly.
2017-09-25 16:19:59 -04:00
Ryan C. Gordon 2b78f64c11 Fixed PHYSFS_flush(). 2017-09-25 16:19:30 -04:00
Ryan C. Gordon 4e0d3d55e9 Make PHYSFS_EnumerateCallback return an enum instead of an int. 2017-08-19 10:40:27 -04:00
Ryan C. Gordon 8dfd3cff8d Fixed some compiler warnings on Visual Studio.
(and maybe made a few new ones...)
2017-08-14 21:15:58 -04:00
Ryan C. Gordon 395ea71990 This appears to have been fixed at some point. 2017-08-14 14:06:43 -04:00
Ryan C. Gordon 660171f79f Don't fail enumeration if a directory isn't available in a given archive.
That shouldn't be a fatal error, that's a normal case.
2017-08-14 14:05:06 -04:00
Ryan C. Gordon f425f051db Little tweaks to __PHYSFS_initSmallAlloc(). 2017-08-14 13:57:57 -04:00
Ryan C. Gordon 8db27a1236 Fix symlink filtering for enumeration under a virtual mount point. 2017-08-14 11:43:18 -04:00
Ryan C. Gordon cfe3f0180b Make PHYSFS_exists() work with mounts from PHYSFS_mountIo(io, NULL, ...)
(Actually, from any mount function that accepts a bogus/NULL filename.)
2017-08-14 03:06:42 -04:00
Ryan C. Gordon 3b7ee3974c Don't set readonly if PHYSFS_stat()'ing something not in the write dir.
This API is meant to report what the archivers think about an item and not
actually tell you if a PHYSFS_openWrite() will succeed on it.
2017-08-14 02:46:07 -04:00
Ryan C. Gordon 63277e500c Turns out we were doing this for a (maybe not good, but reasonable) reason. 2017-08-14 02:42:13 -04:00
Ryan C. Gordon 3078acd1eb Archivers can now specify whether an archive definitely was intended for them.
So if a zip file goes to the zip archiver but is corrupted, the system can now
know not to bother trying other archivers once the zip archiver has had a shot
at it, and just as important: it can report the real error from that archiver
instead of a generic "unsupported."
2017-08-14 02:28:00 -04:00
Ryan C. Gordon dd68246737 7z: do global initialization once without risking a race condition. 2017-08-13 22:53:38 -04:00
Ryan C. Gordon 1364f6a915 PHYSFS_setSaneConfig uses enum callbacks now. 2017-08-13 19:45:31 -04:00
Ryan C. Gordon 0d61295781 Improved some documentation. 2017-08-13 17:11:14 -04:00
Ryan C. Gordon cc3ac9539e Patched to compile on various platforms and compilers. 2017-08-12 03:10:19 -04:00
Ryan C. Gordon 7fcddfb741 Don't mark the PHYSFS_EnumFilesCallback _typedef_ as deprecated.
It upsets several compilers when building PhysicsFS itself.
2017-08-12 03:06:06 -04:00
Ryan C. Gordon ee9687bca9 Reworked enumeration to be more powerful.
Now callbacks can stop further enumeration and report errors, if they had a
catastrophic issue or just found what they needed and don't need to process
any more items.

Also, the actual enumerators can report errors instead of silently dropping
items. This led to several other fixes as all these implementations got
audited and reworked.

The original, non-callback enumerator now returns NULL if it can't produce a
complete list instead of dropping items and returning a partial list.
2017-08-12 02:19:22 -04:00
Ryan C. Gordon d1f2637ca8 utf8: big improvements to case-insensitive UTF-8 string compare.
- Dramatically reduce RAM usage: uses between 8 and 11 kilobytes less static
memory for its internal case-folding tables.
- Actually works now. It would fail unconditionally if a codepoint folded
into multiple codepoints, even if the compared string contained those exact
codepoints.
- Now a public API!
- Removed __PHYSFS_utf8strnicmp(): nothing was using it, it was incorrect
anyhow, and what does 'n' represent when either string might case-fold to
something larger in-flight, anyhow?
2017-08-11 01:39:22 -04:00
Ryan C. Gordon 587ec88a0d FIXME removal: this code is fine, I guess. 2017-08-10 12:31:41 -04:00
Ryan C. Gordon 0e778b0b16 FIXME removal: it's okay for the PHYSFS_Io to be NULL here.
We use this technique in several other places, too.
2017-08-08 15:27:32 -04:00
Ryan C. Gordon eb46d82500 Fixed compiler warnings on GCC. 2017-08-06 15:59:46 -04:00
Ryan C. Gordon af555317b9 Fixed compiler warnings on Visual Studio. 2017-08-06 15:58:39 -04:00
Ryan C. Gordon f0eb5c0db9 Marked a bunch of things as "FIXME-3.0" that I want resolved before 3.0 ships. 2017-08-06 15:54:44 -04:00
Ryan C. Gordon 0287160f3c Removed some FIXMEs that aren't valid. 2017-08-06 13:56:45 -04:00
Ryan C. Gordon 36c51d40d1 PHYSFS_File buffering now uses size_t.
This lets you have the full address space but not take up unnecessary space
on 32-bit platforms...not to mention removes a bunch of typecasting.
2017-08-06 10:33:21 -04:00
Ryan C. Gordon a7ce178eec Add basic atomic operations for refcounting, etc. 2017-08-06 09:21:38 -04:00
Ryan C. Gordon 61bdee4d78 __PHYSFS_platformDeinit() should return void.
What are you going to do if this fails, anyhow?
2017-08-06 01:30:58 -04:00
Ryan C. Gordon 0d249cae36 FIXME removal: This is an appropriate error code already. 2017-08-04 22:32:34 -04:00
Ryan C. Gordon cc2c29b207 Removed FIXME: this was already fixed at some point. 2017-08-04 22:31:56 -04:00
Ryan C. Gordon 6d91dde273 Rename __PHYSFS_Archiver_SZIP to __PHYSFS_Archiver_7Z. 2017-07-22 13:50:03 -04:00
Ryan C. Gordon d3ac612b61 DirTrees and unpacked archives shouldn't demand a count of entries for init. 2017-07-21 13:54:42 -04:00