mirror of
https://github.com/thegatesbrowser/thegates.git
synced 2025-08-24 02:17:27 -04:00
check if path exists
This commit is contained in:
parent
353a01fc2d
commit
a63f4dbe8f
1 changed files with 6 additions and 2 deletions
|
@ -2,6 +2,8 @@ extends Node
|
||||||
class_name FileTools
|
class_name FileTools
|
||||||
|
|
||||||
static func remove_recursive(path: String) -> void:
|
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)
|
var dir = DirAccess.open(path)
|
||||||
if dir:
|
if dir:
|
||||||
# List directory content
|
# List directory content
|
||||||
|
@ -11,11 +13,13 @@ static func remove_recursive(path: String) -> void:
|
||||||
if dir.current_is_dir():
|
if dir.current_is_dir():
|
||||||
remove_recursive(path + "/" + file_name)
|
remove_recursive(path + "/" + file_name)
|
||||||
else:
|
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()
|
file_name = dir.get_next()
|
||||||
|
|
||||||
# Remove current path
|
# Remove current path
|
||||||
dir.remove(path)
|
var err = dir.remove(path)
|
||||||
|
if err != OK: Debug.logerr("Error removing: " + path)
|
||||||
else:
|
else:
|
||||||
Debug.logerr("Error removing " + path)
|
Debug.logerr("Error removing " + path)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue