diff options
author | RĂ©mi Verschelde <remi@verschelde.fr> | 2022-04-12 10:39:54 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-12 10:39:54 +0200 |
commit | f586e06f7b7b1066bc234198a6c11123927cb87c (patch) | |
tree | ea9684d5549f9fc9439ffaf438373f5ca5608a9a /modules/gdscript/gdscript.cpp | |
parent | 2f7edae2b3064714b2e0fe8302366abc658955ce (diff) | |
parent | 4bf99f4af2c4918883c4382ead7de275fae21eea (diff) |
Merge pull request #60166 from bruvzg/narrow_file_access
Diffstat (limited to 'modules/gdscript/gdscript.cpp')
-rw-r--r-- | modules/gdscript/gdscript.cpp | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/modules/gdscript/gdscript.cpp b/modules/gdscript/gdscript.cpp index 269e6f0580..59254fc3ad 100644 --- a/modules/gdscript/gdscript.cpp +++ b/modules/gdscript/gdscript.cpp @@ -2353,14 +2353,16 @@ Error ResourceFormatSaverGDScript::save(const String &p_path, const RES &p_resou String source = sqscr->get_source_code(); - Error err; - Ref<FileAccess> file = FileAccess::open(p_path, FileAccess::WRITE, &err); + { + Error err; + Ref<FileAccess> file = FileAccess::open(p_path, FileAccess::WRITE, &err); - ERR_FAIL_COND_V_MSG(err, err, "Cannot save GDScript file '" + p_path + "'."); + ERR_FAIL_COND_V_MSG(err, err, "Cannot save GDScript file '" + p_path + "'."); - file->store_string(source); - if (file->get_error() != OK && file->get_error() != ERR_FILE_EOF) { - return ERR_CANT_CREATE; + file->store_string(source); + if (file->get_error() != OK && file->get_error() != ERR_FILE_EOF) { + return ERR_CANT_CREATE; + } } if (ScriptServer::is_reload_scripts_on_save_enabled()) { |