| 851 | } |
| 852 | |
| 853 | Error EditorExportPlatformWeb::_export_project(const Ref<EditorExportPreset> &p_preset, int p_debug_flags) { |
| 854 | const String dest = EditorPaths::get_singleton()->get_temp_dir().path_join("web"); |
| 855 | Ref<DirAccess> da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM); |
| 856 | if (!da->dir_exists(dest)) { |
| 857 | Error err = da->make_dir_recursive(dest); |
| 858 | if (err != OK) { |
| 859 | add_message(EXPORT_MESSAGE_ERROR, TTR("Run"), vformat(TTR("Could not create HTTP server directory: %s."), dest)); |
| 860 | return err; |
| 861 | } |
| 862 | } |
| 863 | |
| 864 | const String basepath = dest.path_join("tmp_js_export"); |
| 865 | Error err = export_project(p_preset, true, basepath + ".html", p_debug_flags); |
| 866 | if (err != OK) { |
| 867 | // Export generates several files, clean them up on failure. |
| 868 | DirAccess::remove_file_or_error(basepath + ".html"); |
| 869 | DirAccess::remove_file_or_error(basepath + ".offline.html"); |
| 870 | DirAccess::remove_file_or_error(basepath + ".js"); |
| 871 | DirAccess::remove_file_or_error(basepath + ".audio.worklet.js"); |
| 872 | DirAccess::remove_file_or_error(basepath + ".audio.position.worklet.js"); |
| 873 | DirAccess::remove_file_or_error(basepath + ".service.worker.js"); |
| 874 | DirAccess::remove_file_or_error(basepath + ".pck"); |
| 875 | DirAccess::remove_file_or_error(basepath + ".png"); |
| 876 | DirAccess::remove_file_or_error(basepath + ".side.wasm"); |
| 877 | DirAccess::remove_file_or_error(basepath + ".wasm"); |
| 878 | DirAccess::remove_file_or_error(basepath + ".icon.png"); |
| 879 | DirAccess::remove_file_or_error(basepath + ".apple-touch-icon.png"); |
| 880 | } |
| 881 | return err; |
| 882 | } |
| 883 | |
| 884 | Error EditorExportPlatformWeb::_launch_browser(const String &p_bind_host, const uint16_t p_bind_port, const bool p_use_tls) { |
| 885 | OS::get_singleton()->shell_open(String((p_use_tls ? "https://" : "http://") + p_bind_host + ":" + itos(p_bind_port) + "/tmp_js_export.html")); |
nothing calls this directly
no test coverage detected