0 votes

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()
while true:
    var file = dir.get_next()
    if file == "":
    elif not file.begins_with("."):
        if file.ends_with(type):
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

asked Feb 6, 2019 in Engine by timCopwell (102 points)

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:


It's of course missing Alesis-Fusion-Acoustic-Bass-C2.wav.

I wonder if it's wrapped into project.binary.

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.

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!?

1 Answer

0 votes
Best answer
answered Feb 10, 2019 by ugly_cat (165 points)
selected Feb 11, 2019 by timCopwell

I guess with all my "love" for workarounds that's the best possible way to solve this problem right now. Thanks.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.