Commit Graph

29 Commits

Author SHA1 Message Date
Edgar San Martin, Jr.
7c9ae67706 Add write buffering to Windows SDL_IOStream (#12424) (#14794) 2026-01-12 11:39:06 -08:00
Sam Lantinga
a0307589bd iOS: if the file doesn't exist in the pref path, use the current directory
Fixes https://github.com/libsdl-org/SDL/issues/14743
2026-01-02 08:19:28 -08:00
Sam Lantinga
5f086e7623 Updated copyright for 2026 2026-01-01 09:40:08 -08:00
Anonymous Maarten
9dd3e2305e dlnote: embed trailing semicolon in SDL_ELF_NOTE_DLOPEN macro 2025-12-24 23:45:50 +03:00
Sam Lantinga
22decf4783 Fixed some clang thread-safety warnings 2025-12-02 01:11:38 -08:00
Eddy Jansson
836dad75ae Remove redundant semicolons.
[ci skip]
2025-11-09 07:29:27 -08:00
Mathieu Eyraud
d17b8412f1 Fix potential NULL pointer dereference 2025-11-06 07:24:47 -08:00
Eddy Jansson
aaee09d6ed Don't do NULL-checks before SDL_free()
Replaces the pattern

  if (ptr) {
    SDL_free(ptr);
  }

with

  SDL_free(ptr);
2025-10-20 00:13:09 -07:00
nmlgc
8df057fafc iostream: Properly support the "x" mode for SDL_IOFromFile()
The "x" mode for `fopen()` (open file only if it doesn't exist) used to
be a glibc-exclusive extension, but was later standardized in C11, and
is now also implemented as part of every other widely-used libc:

	* musl: https://git.musl-libc.org/cgit/musl/tree/src/stdio/__fmodeflags.c?id=0ccaf0572e9cccda2cced0f7ee659af4c1c6679a
	* Android Bionic / OpenBSD: 731631f300/libc/upstream-openbsd/lib/libc/stdio/flags.c (86)
	* Apple / FreeBSD: 63976b830a/stdio/FreeBSD/flags.c (L91-L92)

As a result, "x" has already been working on all our automatically
tested platforms that implement `SDL_IOFromFile()` via `fopen()`. So
all we'd be missing for proper support is a Windows implementation
using `CREATE_NEW`, and the documentation that this mode exists and is
intended to work.
2025-10-06 13:23:42 -07:00
ProgramGamer
2c8c2d72b5 Allow in-memory IOStreams to be of length 0 (#13840) 2025-09-27 09:36:30 -07:00
Sam Lantinga
9f9952d53a Fixed filesystem operations on iOS
Full paths are used as-is, relative paths are prepended with a writable path, SDL_GetPrefPath("", ""), since the current directory isn't writable.
2025-09-22 10:09:30 -07:00
Sam Lantinga
25b2d2c821 Use new parameter validation macro 2025-09-18 20:58:32 -07:00
Kyle Sylvestre
3876ce3495 fix windows EOF check 2025-09-16 17:13:22 -07:00
Sam Lantinga
a1d3fc1f50 Clarify why we ignore EINVAL when flushing a file descriptor 2025-09-14 12:11:05 -07:00
Sam Lantinga
e40d337a47 Ignore errors flushing output on POSIX pipes
Fixes https://github.com/libsdl-org/SDL/issues/13116
Fixes https://github.com/libsdl-org/SDL/issues/13412
2025-09-14 12:09:16 -07:00
Ryan C. Gordon
8d5b82be2e io: POSIX implementation tries to get status information on short reads/writes.
Fixes #13413.
2025-09-11 10:11:51 -04:00
Ryan C. Gordon
4d6e0e0087 io: read_fd should only report EOF on a zero-byte return value.
POSIX says that's the EOF indicator, not a non-zero a short read.
2025-09-11 10:11:50 -04:00
Ryan C. Gordon
b8197a2291 io: rework how we set SDL_IOStream status.
This now relies on the implementation to set these flags on short reads/writes
instead of the higher level checking if SDL_SetError() was called.

Additionally (and crucially), this now sets ERROR or EOF on all short reads,
across all backends, not just when we get a zero-byte return value.

Fixes #13720.
2025-09-05 12:43:13 -04:00
Anonymous Maarten
0a6b80717c Record dynamic dependencies in .note.dlopen elf section 2025-08-27 16:11:39 +00:00
Ryan C. Gordon
07ef532681 hints: Renamed SDL_HINT_LOG_BACKENDS to SDL_DEBUG_LOGGING.
This still logs backend choices, but we might use it for other things. For
example, what Android device is being used, or all the devices we enumerated,
etc.

Ideally this eventually logs all the stuff we often have to ask followup
questions about.
2025-07-22 13:19:30 -04:00
Maia
08fd165dd2 Add POINTER suffix to SDL_PROP_IOSTREAM_MEMORY_FREE_FUNC 2025-07-21 10:15:46 -07:00
Marcin Serwin
8451ce86c1 iostream: Add optional free_func pointer property to memory streams
Fixes https://github.com/libsdl-org/SDL/issues/13368

Signed-off-by: Marcin Serwin <marcin@serwin.dev>
2025-07-17 08:59:42 -07:00
Ryan C. Gordon
10004ab0ea hints: Added SDL_HINT_LOG_BACKENDS.
Fixes #13354.
2025-07-14 19:49:38 -04:00
Sam Lantinga
d7939abf42 Use consistent style for pointer declarations and casts 2025-06-18 10:03:44 -07:00
Ryan C. Gordon
10072bb07d asyncio: SDL_LoadFileAsync was not null-terminating the file data. 2025-03-20 15:50:06 -04:00
Petar Popovic
ad11c6988c src/io/SDL_asyncio.c:SDL_AsyncIOFromFile(): Fix null-dereference warning 2025-02-23 11:12:24 -08:00
Sam Lantinga
1c7cc60286 Skip IsRegularFileOrPipe() check on Emscripten
The sandbox guarantees that this will be true.

Fixes https://github.com/libsdl-org/SDL/issues/12108
2025-01-27 22:25:12 -08:00
nightmareci
2e381a717f Fix possible integer overflow of size + 1 2025-01-23 15:57:23 -08:00
Ryan C. Gordon
4d63a2b882 io: Renamed src/file to src/io
Fixes #11980.
2025-01-16 08:18:40 -05:00