How to get an internal resource path in exported binary?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By SamuraiSigma
:warning: Old Version Published before Godot 3 was released.

Hello, fellow Godot users.

I’m developing a Speech to Text (STT) module for Godot (2.1.3 build) using an open source speech recognition library. This library uses configuration files, which I stored inside my experimental game project.

The main problem I’ve encountered is getting the absolute path to the configuration files to work after exporting the game; after all, the library doesn’t recognize res:// paths.

The game works inside the editor, since my module can get absolute paths with the Globals singleton. For example:

Globals::get_singleton()->globalize_path("res://stt/keywords.kws")

The above line converts the file path on my Ubuntu 16.04 to /home/my_user/other_stuff/stt/keywords.kws. However, this absolute path doesn’t work with an exported, binary game (I’ve tried on own Unix system), since the configuration files are stored inside the binary itself.

The only way I’ve found to run the binary would be to place library-related files on the same directory, but that defeats the purpose of having them inside the project in the first place!

I’ve tried looking around the FileAccess and DirAccess Godot classes for a workaround, but with no success. Is there any class/function to accomplish this? Or should I store my library-related files externally (in the user:// path, for example)?

I’d really appreciate any suggestions or comments. :slight_smile:

:bust_in_silhouette: Reply From: SamuraiSigma

From what I’ve discussed with other developers, instead of getting an external path for the config files, it would be best to copy them to user:// at the beginning of the game and get paths from there.