MCPcopy Create free account
hub / github.com/Redot-Engine/redot-engine / save

Method save

modules/gdscript/gdscript.cpp:3153–3176  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3151}
3152
3153Error ResourceFormatSaverGDScript::save(const Ref<Resource> &p_resource, const String &p_path, uint32_t p_flags) {
3154 Ref<GDScript> sqscr = p_resource;
3155 ERR_FAIL_COND_V(sqscr.is_null(), ERR_INVALID_PARAMETER);
3156
3157 String source = sqscr->get_source_code();
3158
3159 {
3160 Error err;
3161 Ref<FileAccess> file = FileAccess::open(p_path, FileAccess::WRITE, &err);
3162
3163 ERR_FAIL_COND_V_MSG(err, err, "Cannot save GDScript file '" + p_path + "'.");
3164
3165 file->store_string(source);
3166 if (file->get_error() != OK && file->get_error() != ERR_FILE_EOF) {
3167 return ERR_CANT_CREATE;
3168 }
3169 }
3170
3171 if (ScriptServer::is_reload_scripts_on_save_enabled()) {
3172 GDScriptLanguage::get_singleton()->reload_tool_script(p_resource, true);
3173 }
3174
3175 return OK;
3176}
3177
3178void ResourceFormatSaverGDScript::get_recognized_extensions(const Ref<Resource> &p_resource, List<String> *p_extensions) const {
3179 if (Object::cast_to<GDScript>(*p_resource)) {

Callers 2

_editor_initFunction · 0.45
queryMethod · 0.45

Calls 5

store_stringMethod · 0.80
is_nullMethod · 0.45
get_source_codeMethod · 0.45
get_errorMethod · 0.45
reload_tool_scriptMethod · 0.45

Tested by

no test coverage detected