![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | timCopwell |
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: Godot_v3.0.6-stable_win64
Just created a quick sample project on Linux and I’m running into the same issue. Here is a list of everything in the res://
directory in a compiled Godot project:
.import
Alesis-Fusion-Acoustic-Bass-C2.wav.import
default_env.tres
icon.png
icon.png.import
main.gd.remap
main.gdc
main.tscn
project.binary
It’s of course missing Alesis-Fusion-Acoustic-Bass-C2.wav
.
I wonder if it’s wrapped into project.binary
.
ugly_cat | 2019-02-06 18:30
At first I thougth it might be something with audio files, but no. I don’t quite understand how your output returns other than .import files. I did remove format check statement and added other files like .ogg and .png to test it out. It’s something I guess… but I only got .import files written in my array by executable.
Edit:
I’m completely lost. I also tried to make fresh project and scan res://
. Now I understand why all files showed up in your example. Also i’ve put custom image inside res://
this time, and well…
[Node.gd.remap, Node.gdc, Node.tscn, spike.png.import, default_env.tres, icon.png, icon.png.import, project.binary]
It’s obvious how spike.png
is missing, but why icon.png
IS !? What’s the difference!?
timCopwell | 2019-02-06 19:34