godot-extended-libraries / godot-next

Godot Node Extensions - Basic Node Extensions for Godot Engine
MIT License
957 stars 61 forks source link

Fix for file_search when providing a non-root directory #80

Closed MinerSebas closed 4 years ago

MinerSebas commented 4 years ago

When providing file_search with a non-root directory it returned an invalid path.

Example Filepath: res://json/file.json Code: FileSearch.search_string(".json", "res://json/") Output: res://jsonfile.json

This happend because the output of .get_current_dir() only ends with an / when its an root like res:// or C:/ .

The code now no longer assumes that you provide a root-directory and instead checks if an / is already present, and appends it when necessary.

willnationsdev commented 4 years ago

Ah, actually, iirc, there is an existing String function dedicated for exactly this: plus_file(...). The implementation should probably use that, unless I'm mistaken. Good catch though!

MinerSebas commented 4 years ago

Didn't know this function existed. Changed the Code to now use it.

willnationsdev commented 4 years ago

@MinerSebas Great. Thanks!