mirror of
https://github.com/godotengine/godot.git
synced 2025-12-08 06:09:55 +00:00
Fix permission handling for backup on write files
This commit is contained in:
parent
1f7630f1bf
commit
587c3134fb
1 changed files with 9 additions and 1 deletions
|
|
@ -148,7 +148,15 @@ Error FileAccessUnix::open_internal(const String &p_path, int p_mode_flags) {
|
|||
last_error = ERR_FILE_CANT_OPEN;
|
||||
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());
|
||||
|
||||
f = fdopen(fd, mode_string);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue