-
-
Notifications
You must be signed in to change notification settings - Fork 97
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a DirAccess method to remove a non-empty directory #11598
Comments
If you want to recursively delete a directory you could probably do this: func remove_recursive(directory: String) -> void:
for dir_name in DirAccess.get_directories_at(directory):
remove_recursive(directory.path_join(dir_name))
for file_name in DirAccess.get_files_at(directory):
DirAccess.remove_absolute(directory.path_join(file_name))
DirAccess.remove_absolute(directory) |
Yes but it would still be better to just have one method to do it |
Technically you could do |
That only works on Linux and Mac, not Windows. |
I never said anything about it being a good solution. Personally I don't think such a method is necessary given that it's trivial to write a custom method and put it in a utils class |
Describe the project you are working on
A 2D physics based rage game
Describe the problem or limitation you are having in your project
Deleting a directory of save data is annoying to do
Describe the feature / enhancement and how it helps to overcome the problem or limitation
Add ability to delete an entire (non-empty) directory and all the files in it
Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams
DirAccess.idk_what_the_function_would_be_called("user://save")
If this enhancement will not be used often, can it be worked around with a few lines of script?
Currently I am manually updating a list of all the files to be deleted and using a for loop to loop through and delete them all. This is very inconvenient and annoying.
Is there a reason why this should be core and not an add-on in the asset library?
It is super easy to implement and will probably only take around 5-10 lines of code
The text was updated successfully, but these errors were encountered: