Skip to content

Commit 773ea27

Browse files
committed
feat: ✨ added get_dir_paths_in_dir()
1 parent 0434f74 commit 773ea27

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

addons/mod_loader/internal/path.gd

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,30 @@ static func get_file_paths_in_dir(src_dir_path: String) -> Array:
126126
return file_paths
127127

128128

129+
# Returns an array of directory paths inside the src dir
130+
static func get_dir_paths_in_dir(src_dir_path: String) -> Array:
131+
var dir_paths := []
132+
133+
var directory := Directory.new()
134+
var error := directory.open(src_dir_path)
135+
136+
if not error == OK:
137+
return dir_paths
138+
ModLoaderLog.error("Error opening directory", LOG_NAME)
139+
140+
directory.list_dir_begin()
141+
var file_name := directory.get_next()
142+
while (file_name != ""):
143+
if file_name == "." or file_name == "..":
144+
file_name = directory.get_next()
145+
continue
146+
if directory.current_is_dir():
147+
dir_paths.push_back(src_dir_path.plus_file(file_name))
148+
file_name = directory.get_next()
149+
150+
return dir_paths
151+
152+
129153
# Get the path to the mods folder, with any applicable overrides applied
130154
static func get_path_to_mods() -> String:
131155
var mods_folder_path := get_local_folder_dir("mods")

0 commit comments

Comments
 (0)