In order to extract a zip, I followed: https://godotforums.org/discussion/comment/58851
In this, the command ProjectSettings.load_resource_pack(zip_file)
is required.
My question is: How do I unload the resource pack when done extracting?
Because having loaded the resource pack leads to problems afterwards using Dir.
For example, in the following function, I try to list all files inside path
, however dir.get_next() returns the files inside zip_file
isntead of path
.
func ListItemsInDirectory(path):
var items = []
var dir = Directory.new()
dir.open(path)
dir.list_dir_begin(true, false)
while true:
var file = dir.get_next()
if file == "":
break
items.append(file)
dir.list_dir_end()
return items
Or a second example, the following does not work anymore, probably because it is again looking inside zip_file
instead of res://
var dir = Directory.new()
dir.remove(sourceFile)