From a63f4dbe8faedde8bed6ae04da0672e61e17c1bb Mon Sep 17 00:00:00 2001 From: Nordup Date: Sun, 2 Apr 2023 01:56:08 +0300 Subject: [PATCH] check if path exists --- project/the_gates/scripts/loading/file_tools.gd | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/project/the_gates/scripts/loading/file_tools.gd b/project/the_gates/scripts/loading/file_tools.gd index 9e63baf..ac0aea6 100644 --- a/project/the_gates/scripts/loading/file_tools.gd +++ b/project/the_gates/scripts/loading/file_tools.gd @@ -2,6 +2,8 @@ extends Node class_name FileTools static func remove_recursive(path: String) -> void: + if not DirAccess.dir_exists_absolute(path) and not FileAccess.file_exists(path): return + var dir = DirAccess.open(path) if dir: # List directory content @@ -11,11 +13,13 @@ static func remove_recursive(path: String) -> void: if dir.current_is_dir(): remove_recursive(path + "/" + file_name) else: - dir.remove(file_name) + var err = dir.remove(file_name) + if err != OK: Debug.logerr("Error removing: " + path + "/" + file_name) file_name = dir.get_next() # Remove current path - dir.remove(path) + var err = dir.remove(path) + if err != OK: Debug.logerr("Error removing: " + path) else: Debug.logerr("Error removing " + path)