From aaa9610aaf84cb0ecfe244393845a862263672d4 Mon Sep 17 00:00:00 2001 From: Wellington Dias Date: Sat, 31 Oct 2026 02:02:27 -0300 Subject: [PATCH] Refuse to replace a read-only file in plat_file_write_atomic on Linux, as Windows does, so a read-only totk.ini stays as the player left it. --- runtime/platform/linux.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/runtime/platform/linux.c b/runtime/platform/linux.c index 677b4b1d..cc9d07a9 100644 --- a/runtime/platform/linux.c +++ b/runtime/platform/linux.c @@ -723,6 +723,9 @@ int plat_file_replace(const char *from, const char *to) { } int plat_file_write_atomic(const char *path, const void *data, size_t n) { + // A rename replaces a read-only file here (only the folder's permission counts) but not on Windows: a file the + // player made read-only stays as it is on both. + if (access(path, W_OK) && errno != ENOENT) return 0; char tmp[PATH_MAX + 48]; int len = snprintf(tmp, sizeof tmp, "%s.%u.%u.tmp", path, plat_process_id(), plat_thread_id()); if (len < 0 || len >= (int)sizeof tmp) return 0;