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

Method _execute

editor/export/editor_export_platform_apple_embedded.cpp:2657–2696  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2655};
2656
2657int EditorExportPlatformAppleEmbedded::_execute(const String &p_path, const List<String> &p_arguments, std::function<void(const String &)> p_on_data) {
2658 Dictionary pipe_info = OS::get_singleton()->execute_with_pipe(p_path, p_arguments, false);
2659 ERR_FAIL_COND_V_MSG(pipe_info.is_empty(), 1, "execute_with_pipe failed");
2660
2661 Ref<FileAccess> fa_stdout = pipe_info["stdio"];
2662 Ref<FileAccess> fa_stderr = pipe_info["stderr"];
2663 OS::ProcessID pid = pipe_info["pid"];
2664
2665 FileReader stdout_r(fa_stdout);
2666 FileReader stderr_r(fa_stderr);
2667
2668 while (true) {
2669 String output;
2670 stdout_r.get_lines(output);
2671 stderr_r.get_lines(output);
2672 if (!output.is_empty()) {
2673 p_on_data(output);
2674 }
2675
2676 // If the process is no longer running and no new data arrived, we're done.
2677 if (output.is_empty() && !OS::get_singleton()->is_process_running(pid)) {
2678 break;
2679 }
2680
2681 OS::get_singleton()->delay_usec(1000);
2682 }
2683
2684 // Flush any remaining content
2685 String output;
2686 stdout_r.flush(output);
2687 stderr_r.flush(output);
2688 if (!output.is_empty()) {
2689 p_on_data(output);
2690 }
2691
2692 fa_stdout->close();
2693 fa_stderr->close();
2694
2695 return OS::get_singleton()->get_process_exit_code(pid);
2696}
2697
2698#endif
2699

Callers

nothing calls this directly

Calls 8

get_linesMethod · 0.80
closeMethod · 0.65
execute_with_pipeMethod · 0.45
is_emptyMethod · 0.45
is_process_runningMethod · 0.45
delay_usecMethod · 0.45
flushMethod · 0.45
get_process_exit_codeMethod · 0.45

Tested by

no test coverage detected