I have a following function in my scene, which scans directories for files of specified format.
func list_files_in_directory(path , type):
var files = []
var dir = Directory.new()
dir.open(path)
dir.list_dir_begin()
while true:
var file = dir.get_next()
if file == "":
break
elif not file.begins_with("."):
if file.ends_with(type):
files.append(file)
dir.list_dir_end()
return files
Example command:
print(list_files_in_directory("res://audio", ".wav"))
Will return this:
[goodluck.wav, laugh.wav, missing.wav, noise.wav, takeout.wav]
Which is correct. Such directory as "res://audio" has exactly 5 .wav files. (It excepts .import files, so everything works as intended)
The problem comes out when I export the project as .exe on Windows.
Without changing anything in code, after opening this scene, function returns value with empty array i.e
[]
Am I missing something ?
I tried defining it within both _ready() and _process() functions, neither of them return expected value.
Godot version: Godotv3.0.6-stablewin64