Add-on with basic functionnality for my Godot projects
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

22 lines
557 B

tool
# Resources tools
static func list_from_dir(path: String, pattern="*") -> PoolStringArray:
""" List all resources in a directory (non-recursive)
"""
var result := PoolStringArray()
path = path.rstrip("/")
var dir := Directory.new()
if dir.open(path) == OK:
dir.list_dir_begin()
var file_name := dir.get_next()
while file_name != "":
if file_name.match(pattern) and not dir.current_is_dir():
result.append(path + "/" + file_name)
file_name = dir.get_next()
else:
push_error("Can't read directory: %s" % path)
return result