Skip to content

armgit / godot

Public Imported from GitHub
0

Godot Engine – Multi-platform 2D and 3D game engine

Fix file deletion error in Web Editor

Shiva Karfe902d18b6eb
diff --git a/platform/web/os_web.cpp b/platform/web/os_web.cpp
index 0adf0199671..39f1393ee5c 100644
--- a/platform/web/os_web.cpp
+++ b/platform/web/os_web.cpp
@@ -268,6 +268,18 @@ Error OS_Web::pwa_update() {
return godot_js_pwa_update() ? FAILED : OK;
}
+Error OS_Web::move_to_trash(const String &p_path) {
+ if (DirAccess::dir_exists_absolute(p_path)) {
+ Ref<DirAccess> da = DirAccess::open(p_path);
+ ERR_FAIL_COND_V(da.is_null(), ERR_BUG);
+ Error err = da->erase_contents_recursive();
+ if (err) {
+ return err;
+ }
+ }
+ return DirAccess::remove_absolute(p_path);
+}
+
bool OS_Web::is_userfs_persistent() const {
return idb_available;
}
diff --git a/platform/web/os_web.h b/platform/web/os_web.h
index e581e9a945a..1c8544d7147 100644
--- a/platform/web/os_web.h
+++ b/platform/web/os_web.h
@@ -114,6 +114,8 @@ public:
Error open_dynamic_library(const String &p_path, void *&p_library_handle, GDExtensionData *p_data = nullptr) override;
+ Error move_to_trash(const String &p_path) override;
+
void resume_audio();
OS_Web();