Commit Graph

48 Commits

Author SHA1 Message Date
bjorn 1d1470f042 Fix directory archive path normalization;
Fixes non-normalized paths not behaving as expected.
2023-03-09 21:27:04 -08:00
bjorn 06dad182db Fix mounted directories with non-empty mountpoints;
Mounting directories with mountpoints wasn't treating the components
in the mountpoint path as virtual directories.
2022-12-10 18:25:09 -08:00
bjorn 74a9b90e93 Fix zip archive enumeration;
Zip archives weren't enumerating in the root directory when they were
mounted with a non-empty mountpoint.  Additionally, zips mounted at the
root directory weren't listing files properly.  This fixes both by
normalizing the mountpoint prefix (it had a prepended slash when it was
empty, which messed up hashing), and ensuring there is a "root node" in
the tree with an empty string.
2022-12-10 18:25:09 -08:00
bjorn 8f74778c19 Error if require path is too long instead of truncating; 2022-11-23 14:08:32 -08:00
bjorn 4483145d53 Allow passing a file to lovr;
The file will be treated as main.lua.
Its directory will be treated as the source.
2022-04-28 17:36:05 -07:00
bjorn cd0e458af9 lovr.filesystem.write/append returns success instead of size;
We don't have a good way of returning filesystem error messages yet,
but it's still useful to return a boolean instead of a number to
detect failure of zero byte writes.  Exposing the number of bytes
written is kind of weird since it's not very actionable.
2022-03-30 22:45:09 -07:00
bjorn 5d271de91a mv map util; 2022-03-30 12:34:38 -07:00
bjorn 301f7b2cc9 Android mounts save directory earlier;
This fixes issues with conf.lua not getting read properly, and also
the weird quirk of getIdentity not working until setIdentity runs.
2022-03-23 18:27:05 -07:00
bjorn 2da18d419b mv util src; 2022-03-22 00:13:38 -07:00
bjorn c9fe026a66 Fix undefined behavior in arr_free;
Currently there is a single allocator function used in arr_t.  Its
behavior depends on the values for the pointer and size arguments:

- If pointer is NULL, it should allocate new memory.
- If pointer is non-NULL and size is positive, it should resize memory.
- If size is zero, it should free memory.

All instances of arr_t use realloc for this right now.  The problem
is that realloc's behavior is undefined when the size argument is zero.
On Windows and Linux, realloc will free the pointer, but on macOS this
isn't the case.  This means that arr_t leaks memory on macOS.

It's best to not rely on undefined behavior like this, so let's instead
use a helper function that behaves the way we want.
2022-03-14 12:27:58 -07:00
bjorn 895589c914 Add even more padding to stb zlib; 2021-03-24 21:13:04 -06:00
bjorn 0bb556554d Probably work around stb_image bug that breaks zips;
30e01f upgraded stb_image to include its 95560b commit from its #960
pull request.  This made stb_image fail more aggressively on EOF
conditions when refilling huffman buffers in deflate streams.  I think
it might be failing _too_ aggressively, though.  We are able to pad our
input compressed buffers since the zip file format is guaranteed to have
extra data at the end (for, e.g., the end of central directory record).
This appears to be sufficient to fix compressed zip archives for the
time being.  It's possible that more virtual padding needs to be added,
and it may be good to try to fix this in stb_image itself.
2021-03-18 00:05:34 -06:00
bjorn f82e8112fe Simplify filesystem arguments; 2021-02-25 10:45:45 -07:00
bjorn 4f5adbc64c lovr.system; 2021-02-25 09:00:12 -07:00
bjorn 6d92d54079 Try having arr_t in util; 2021-02-08 18:25:05 -07:00
bjorn b356ce2546 Plugins;
- The plugins folder can contain native plugins.
- CMake will build plugins with CMakeLists in them
  - They can check the LOVR variable to see if they are being built inside LOVR.
  - They can set the LOVR_PLUGIN_TARGETS variable to a list of targets they build.
    - If blank, all non-imported targets added in the folder will be used.
  - The libraries built by their targets will be moved next to the executable or into the apk.
- The library loader now tries to load libraries next to the executable or in the APK.
  - It is "fixed function" now, this may be improved in the future.
- The lovr.filesystem C require path has been removed.
- enet and cjson have been removed.  Use plugins.
2020-12-28 12:37:35 -07:00
bjorn 25811f1c01 Change default require paths;
The lua_modules+deps paths were added for a LuaRocks experiment.
2020-12-25 12:20:58 -07:00
bjorn a055caaae4 Fix file permissions; 2020-08-22 13:36:39 -06:00
bjorn 4160743b77 Fix desktop game packaging issue;
Accidentally hardcoded it to "assets" when updating Android.
2020-07-29 16:30:14 -06:00
bjorn 826fc098bc Set identity to empty string if save mount fails; 2020-07-29 16:27:17 -06:00
Bjorn 617d508d68
Merge pull request #269 from jmiskovic/savemount
Config parameter for save directory precedence
2020-07-29 16:26:07 -06:00
bjorn ae2e14f98f rm save directory mount failure fix;
This is a temporary revert to make a merge easier.
2020-07-29 16:25:29 -06:00
bjorn c423b1292a Fix save directory to use system path separator; 2020-07-27 18:15:16 -06:00
bjorn 0dd4a1191c rm getApplicationId; 2020-06-29 18:10:03 -06:00
bjorn afaae2febb Remaining android filesystem work; 2020-06-25 18:18:44 -06:00
bjorn 2042010b5b Move core/fs paths to core/os;
Usually these are more of a platform-specific concept, and they
don't really interact with files or do any io.

There is a little bit of duplication among the *nix platforms since
they're similar, but overall this organization feels a bit better.
2020-06-25 13:28:40 -06:00
Josip Miskovic 66d7e887c7 Config parameter for save directory precedence 2020-06-21 18:02:36 +03:00
bjorn 75e26f0051 Move core/hash to core/util; 2020-05-19 13:49:40 -06:00
bjorn 7d316d6218 Add internal filesystem module comment; 2020-04-22 01:47:16 -06:00
bjorn 93d556b603 zip: read compressed size from central directory;
Some zip writers do not write the compressed size to the local file
headers.
2020-02-21 15:44:48 -08:00
mcc 7db4e4976b Fix compile warnings (MSVC2019) 2020-02-17 17:42:13 -05:00
bjorn f207c4d9a4 zip: Only call munmap if zip file was actually mapped; 2020-01-20 15:59:53 -08:00
mcc ea06f8d7dc Filesystem fixes: Use normalize() in lovrFilesystemMount and dir_resolve; ensure enough room for zero terminator in zip_lookup 2020-01-20 17:12:37 -05:00
bjorn d1657f401d Fix some memory leaks; 2019-12-20 04:13:38 -08:00
bjorn 403ed8d3b0 Windows; 2019-12-10 12:19:50 -08:00
bjorn 488c125c5f Draw the rest of the owl; 2019-12-10 12:19:50 -08:00
Nevyn Bengtsson ab6e4891e1 Cast objc_msgSend before calling it
Calling objc_msgSend with its vararg signature will only work most
of the time, and fail very weirdly when it doesn't. It's weird,
but you're supposed to always cast it to the signature of the
selector you're calling.

I think this is even required when building on Catalina, or for arm64?
2019-10-15 22:00:15 +02:00
bjorn 25fa80f1d5 Fix comment; 2019-10-14 16:10:34 -07:00
bjorn c3f91e9ff3 Actually fix/test the issue with .lovr files on macOS apps; 2019-10-14 15:24:02 -07:00
bjorn 2e44926767 Cleanup; 2019-09-26 20:19:50 -07:00
bjorn 0129a80b27 Load .lovr files from the macOS app bundle; 2019-09-24 21:37:44 -07:00
bjorn cd09e1e695 rm sds; 2019-08-21 16:30:20 -07:00
bjorn 4372eb293e rm comma operator;
everyone is making fun of me haha
2019-07-10 18:46:51 -07:00
bjorn eb1e257209 Add new array implementation; Upgrade filesystem;
Filesystem:

- Uses streaming file IO.
- Uses less memory when requiring files.
- Simplifies its require path implementation.
2019-06-16 13:30:30 -07:00
bjorn d5ad10f408 Permit symbolic links in lovr.filesystem;
If needed, it can be made configurable later.
2019-05-24 19:16:43 -07:00
bjorn 67ddefd0c2 Ensure platform functions have prefix; 2019-05-20 04:02:25 -07:00
bjorn b1e848ef6b Cleanup filesystem module; 2019-05-20 03:51:22 -07:00
bjorn a17f10e273 Add modules folder; 2019-05-19 00:38:35 -07:00
Renamed from src/filesystem/filesystem.c (Browse further)