1
0
mirror of https://github.com/godotengine/godot.git synced 2025-12-02 16:48:55 +00:00

Fix permission handling for backup on write files

This commit is contained in:
GlitchedCode922
2025-09-26 18:07:17 +03:00
parent 1f7630f1bf
commit 587c3134fb

View File

@@ -148,7 +148,15 @@ Error FileAccessUnix::open_internal(const String &p_path, int p_mode_flags) {
last_error = ERR_FILE_CANT_OPEN; last_error = ERR_FILE_CANT_OPEN;
return last_error; return last_error;
} }
fchmod(fd, 0644);
struct stat file_stat = {};
int error = stat(save_path.utf8().get_data(), &file_stat);
if (!error) {
fchmod(fd, file_stat.st_mode & 0xFFF); // Mask to remove file type
} else {
fchmod(fd, 0644); // Fallback permissions
}
path = String::utf8(cs.ptr()); path = String::utf8(cs.ptr());
f = fdopen(fd, mode_string); f = fdopen(fd, mode_string);