| 3151 | } |
| 3152 | |
| 3153 | Error 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 | |
| 3178 | void ResourceFormatSaverGDScript::get_recognized_extensions(const Ref<Resource> &p_resource, List<String> *p_extensions) const { |
| 3179 | if (Object::cast_to<GDScript>(*p_resource)) { |
no test coverage detected