| 2474 | } |
| 2475 | |
| 2476 | Ref<TextFile> ScriptEditor::_load_text_file(const String &p_path, Error *r_error) const { |
| 2477 | if (r_error) { |
| 2478 | *r_error = ERR_FILE_CANT_OPEN; |
| 2479 | } |
| 2480 | |
| 2481 | String local_path = ProjectSettings::get_singleton()->localize_path(p_path); |
| 2482 | String path = ResourceLoader::path_remap(local_path); |
| 2483 | |
| 2484 | TextFile *text_file = memnew(TextFile); |
| 2485 | Ref<TextFile> text_res(text_file); |
| 2486 | Error err = text_file->load_text(path); |
| 2487 | |
| 2488 | ERR_FAIL_COND_V_MSG(err != OK, Ref<Resource>(), "Cannot load text file '" + path + "'."); |
| 2489 | |
| 2490 | text_file->set_file_path(local_path); |
| 2491 | text_file->set_path(local_path, true); |
| 2492 | |
| 2493 | if (ResourceLoader::get_timestamp_on_load()) { |
| 2494 | text_file->set_last_modified_time(FileAccess::get_modified_time(path)); |
| 2495 | } |
| 2496 | |
| 2497 | if (r_error) { |
| 2498 | *r_error = OK; |
| 2499 | } |
| 2500 | |
| 2501 | return text_res; |
| 2502 | } |
| 2503 | |
| 2504 | Error ScriptEditor::_save_text_file(Ref<TextFile> p_text_file, const String &p_path) { |
| 2505 | Ref<TextFile> sqscr = p_text_file; |
no test coverage detected