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

Method _load_text_file

editor/script/script_editor_plugin.cpp:2476–2502  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2474}
2475
2476Ref<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
2504Error ScriptEditor::_save_text_file(Ref<TextFile> p_text_file, const String &p_path) {
2505 Ref<TextFile> sqscr = p_text_file;

Callers 1

_open_script_requestMethod · 0.80

Calls 5

localize_pathMethod · 0.80
load_textMethod · 0.80
set_file_pathMethod · 0.80
set_pathMethod · 0.45

Tested by

no test coverage detected