mirror of
https://github.com/valentderah/totk-pc-recomp.git
synced 2026-11-19 04:15:57 +00:00
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.
This commit is contained in:
1 parent
a4c99a47b0
commit
aaa9610aaf
1 file changed
+3
@@ -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;
|
||||
|
||||
Reference in new issue
Block a user