Created
August 6, 2016 20:18
-
-
Save YeOldeDM/1338f93c98523e5e13596c16b77ac969 to your computer and use it in GitHub Desktop.
delete a folder, and all contents of that folder
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func _delete_data(path): | |
var dir = Directory.new() | |
var opened = dir.change_dir(path) | |
if opened != OK: | |
OS.alert("Error "+str(opened)+" opening path: "+path) | |
dir.list_dir_begin() | |
var current = dir.get_next() | |
print(current) | |
while not current.empty(): | |
if dir.current_is_dir(): | |
if !current.begins_with('.'): | |
_delete_data(path+'/'+current) | |
else: | |
var removed = dir.remove(path+'/'+current) | |
if !removed==OK: | |
OS.alert("Error "+str(removed)+" deleting: "+current) | |
current = dir.get_next() | |
var deleted = dir.remove(path) | |
if !deleted==OK: | |
OS.alert("Error "+str(deleted)+" deleting: "+path) | |
return deleted |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment