Commit graph

597 commits

Author SHA1 Message Date
Donovan Watteau
858847e1ba BACKENDS: FS: Use stat() fallback for all unexpected dirent d_type values
On systems where dirent provides a `d_type` field, we currently fall
back to stat() only for DT_UNKNOWN values.

Do so for all unexpected `d_type` values instead (that is, anything
different from DT_DIR, DT_REG and DT_LNK).

This is because there's no guarantee that `d_type` will be meaningful
for all OSes and filesystems. One such example is macOS Tiger, where
`d_type` will hold bogus values for the .aiff files of cddafs mount
points (as triggered by MacOSXAudioCDManager). (This bug appears to
have been fixed in cddafs-242.0.1, around the Snow Leopard area.)

When using stat() over the same files, the proper file type is
returned, though. Hence the need for the stat() fallback to be
triggered in more cases than DT_UNKNOWN.

This fixes Indy3 FM-TOWNS music being silent on macOS Tiger, when
playing from the original CD.
2025-03-26 11:50:53 +08:00
Le Philousophe
402f31122c ANDROID: Don't track SAFFSNode using JNI global references anymore
The JNI global references are limited in count and we overflow it for
games with a huge number of files (like Zork Nemesis).
Instead, track all the nodes from Java side using a unique identifier
generated using an atomic counter.
Then, all JNI calls either use a temporary local reference to access
node data or use the unique identifier.
2025-01-26 18:17:05 +01:00
Le Philousophe
e08b8203bc ANDROID: Use a SharedPtr to track SAF tree global references
This makes us use a single global reference per tree instead of
duplicating them on each filesystem node creation.
Thanks to the SharedPtr, the global reference is automatically
deallocated when needed.
This is the first step to avoid global references overflow.
2025-01-26 18:17:05 +01:00
Le Philousophe
3c4df9614a ANDROID: Don't call error too early
When the backend is not yet set up, avoid using error which ends up
using exit without any useful error log.
2025-01-26 18:17:05 +01:00
Hubert Maier
f54fd81b4f
JANITORIAL: Fix typos in general files 2024-12-25 16:57:34 +02:00
Vladimir Serbinenko
e20adda52d KOLIBRI: Use _ksys_getcwd instead of getcwd
getcwd is apprently missing from SDK I tried. Whatever, just use _ksys_getcwd
2024-12-06 17:17:11 +02:00
Cameron Cawley
234dc99fd3 RISCOS: Don't encode path when it's not needed
Also disable atomic support as it may fail to write when file names are
long.
2024-12-04 22:41:14 +00:00
BeWorld
52fbe6620a
BACKENDS: MORPHOS: enhanced init and add features
- Add initBackend (same as AmigaOS)
- Add getSystemLanguage() to detect system language (use SDL_GetPreferredLocales)
2024-11-23 19:24:02 +02:00
Hubert Maier
cd74fff5f4 JANITORIAL: Add missing closing bracket in amigaos-fs.cpp 2024-11-10 14:49:50 +02:00
Le Philousophe
0e86eda0be BACKENDS: FS: Fix Atari
Atari only support 8.3 file names and adding a tmp suffix for atomic
writes breaks this.
Make the WriteMode_WriteAtomic flag available in all cases and fall back
on unatomic write in this case.
2024-10-27 11:46:16 +01:00
Le Philousophe
08c9131b1a BACKENDS: FS: Fix Dreamcast build 2024-10-15 22:45:50 +02:00
sluicebox
e61ad40d2f BACKENDS: WIN32: Use Win32 specific API to move file atomically
This avoids to remove the destination file before moving the temporary one.

Co-authored-by: Le Philousophe <lephilousophe@users.noreply.github.com>
2024-10-15 22:45:50 +02:00
Le Philousophe
fdd11d0714 BACKENDS: FS: Implement atomic file write for stdio stream backend
This implementation creates a temporary file (suffixed with .tmp) and
renames it to the expected file name when the file is closed.
If the renaming fails, the destination file is removed and renaming is
tried again to handle cases where renaming over an existing file is not
supported by the underlying OS.
2024-10-15 22:45:50 +02:00
Le Philousophe
e61dac6c68 BACKENDS: Allow write streams to be created atomically
When creating an atomic write stream, the file is only created once it
is closed.
This can be done using a temporary file.
This commit only adds the API but not the proper implementation.
2024-10-15 22:45:50 +02:00
Le Philousophe
9c10591f51 BACKENDS: FS: Fix build 2024-10-03 08:38:52 +02:00
Le Philousophe
0c60d29694 Revert "BACKENDS: FS: Make file writing atomic"
This reverts commit 99dc7641a9.
This causes bug #15392, a build failure on Dreamcast and changes too
much the semantics.
A better approach will need to be found, especially for streaming files
like logs.
2024-10-03 08:35:57 +02:00
Le Philousophe
99dc7641a9 BACKENDS: FS: Make file writing atomic
A temporary file is used to write the data and the file is renamed when
it is closed.
The string containing the destination path is a stored as a pointer to
limit the size of the object (which is already doubled).
2024-10-01 22:43:38 +02:00
Le Philousophe
5d0d6b7379 BACKENDS: FS: Refactor StdioStream::makeFromPath
This allows to avoid code duplication with PosixIoStream
2024-10-01 22:43:38 +02:00
sluicebox
0887df6b39 WIN32: Fix memory leak in WindowsFilesystemNode
20 years old: be58f22feb
2024-09-18 01:06:59 -07:00
Le Philousophe
867cbfcd0d ANDROID: Create a dedicated define for Android backend
This allows other backends (SDL, libretro) to be used on Android without
hacks.
2024-09-02 20:53:57 +03:00
Vladimir Serbinenko
3bc7902b6a
KOLIBRI: Update for new ksys.h
New ksys has renamed few structs and function. Propagate rename and
use _ksys_file_read_dir function instead of manual filling
2024-01-20 23:52:46 +01:00
Cameron Cawley
4fdd1f7cc0 CONFIGURE: Check if fopen64 is available before using it 2024-01-08 16:23:00 +02:00
Thierry Crozat
ab13d18e58 BACKENDS: Add function in FS Factory to map scummvm path to system path
In most cases they are the same, but in the case of a sandboxed filesystem,
they may be different. Mapping to the full system path allows using the
path with system functions, such as fopen() or third party libraries (for
example to pass a soundfont path to the fluidsynth library).
2023-12-03 16:17:32 +00:00
elasota
9892bedc61 COMMON: Add createReadStreamForAltStream to open Mac resource fork and metadata streams 2023-08-30 00:31:00 +02:00
Le Philousophe
6c248275c8 ANDROID: Fix assertion fault and missing initializer 2023-04-22 12:28:22 +02:00
antoniou79
42991838c5 ANDROID: Comments on Android storage
And a minor comment fix
2023-03-27 14:12:09 +03:00
Thierry Crozat
cbd2b736df BACKENDS: Add possibility to specify virtual drive in ChRootFilesystemFactory
It allows to get access to additional directories outside of the sandbox root.
This is used on iOS to access files in the app bundle.
2023-03-24 21:11:50 +01:00
Le Philousophe
acccb564cb ANDROID: Don't crash when fetchChildren failed in Java 2023-03-18 12:01:05 +01:00
Eugene Sandulenko
1f49e54599
ANDROID: Avoid including translations.h in a header 2023-03-17 14:42:55 +01:00
Donovan Watteau
18ab6803d6 JANITORIAL: Fix various "an" typos in comments 2023-03-16 14:47:28 +01:00
Le Philousophe
55c9a7529f ANDROID: Don't keep a _cache variable, it's never checked 2023-03-04 18:16:20 +01:00
Le Philousophe
316a6974ba ANDROID: Slightly optimize and rewrite cacheData 2023-03-04 18:16:20 +01:00
Le Philousophe
4bcd7084db ANDROID: Add missing header for Android filesystem specific 2023-02-28 19:31:59 +01:00
Le Philousophe
075c3f4246 ANDROID: Add remove feature to Android filesystem abstraction 2023-02-28 19:12:11 +02:00
Le Philousophe
625c1d10c8 ANDROID: Allow SAF non-existent node creation from path
This is used by DumpFile.
As in all other implementations, parent node is expected to exist.
2023-02-26 12:20:13 +01:00
Le Philousophe
9d879cb04f ANDROID: Allow to create a /saf node from path
This avoids errors when creating parent directories in DumpFile
This also allows the user to specify /saf path in browser to allow
browsing.
2023-02-26 12:20:13 +01:00
Le Philousophe
a8692ebf13 ANDROID: Make SAF strings translatable and better looking 2023-02-12 17:54:45 +01:00
Vladimir Serbinenko
4bcd4671ab KOLIBRI: Add kolibrios backend 2023-02-05 22:55:40 +01:00
Le Philousophe
baf42ae7e6 ANDROID: Add a dialog to revoke SAF authorizations
Remove old all-in-one revoke authorizations process
2023-01-20 14:14:03 +01:00
Le Philousophe
a465718c24 ANDROID: Fix comment
For coherence sake
2023-01-20 14:14:03 +01:00
Le Philousophe
ca1dbfc9d6 ANDROID: Add SAF support 2023-01-20 14:14:03 +01:00
Le Philousophe
0fdf53f984 ANDROID: Remove platform specific code from shared code 2023-01-20 14:14:03 +01:00
Le Philousophe
54fd20c36c POSIX: Refactor DrivePOSIXFilesystemNode to allow for dynamic drives 2023-01-20 14:14:03 +01:00
Le Philousophe
787d4e1db6 POSIX: Allow to subclass DrivePOSIXFilesystemNode
Without this, there are some cases where the nodes created are not the
subclass.
Also make _config available to derived classes.
2023-01-20 14:14:03 +01:00
Donovan Watteau
0eb9ca84de BACKENDS: Make StdioStream use a 64-bit fseeko/ftello on more platforms
Note that using fseeko64() means that fopen64() should be used instead.
2022-12-11 21:48:33 +01:00
elasota
cc11b531e3 JANITORIAL: Clean up all non-engine Visual Studio warnings. 2022-12-04 00:08:48 +01:00
Le Philousophe
43997e2911 WIN32: Don't use unsafe sprintf and vsprintf 2022-10-23 22:46:19 +02:00
Le Philousophe
a60e8ff2cb MORPHOS: Don't use unsafe sprintf and vsprintf 2022-10-23 22:46:19 +02:00
Le Philousophe
7c657796f4 POSIX: Don't use unsafe strcat and strcpy
It was commented but still
2022-10-23 22:46:19 +02:00
Le Philousophe
15e7346f1c MORPHOS: Don't use unsafe strcat and strcpy 2022-10-23 22:46:19 +02:00