Compare commits

...

4 Commits

3 changed files with 20 additions and 2 deletions

View File

@ -5,7 +5,7 @@
## Recursively creates virtual file systems.
static func create_meta_accessor(file_accessors:Array[VFileAccess])->VFileAccess:
var vfiler := VFileAccess.new()
var vfiler := VFileAccess.new("")
vfiler._get_stuff = func()->Variant: return file_accessors

18
vfs.gd
View File

@ -101,6 +101,24 @@ func load_supported(path:String, ext_override:String = "")->Variant:
return result
## Like load_supported, but expects [param path] to not have an extension.
## Instead, [param extensions] can contain multiple extensions, which will be
## appended and checked to exist. This allows for prioritizing one format
## over another or loosely defining a file id and allowing the engine to
## find a first match.
func load_any_supported(base_path:String, extensions:Array[String] = [])->Variant:
var _append_ext := func _append_ext(ext:String)->String:
return (base_path + ext) \
if ext.begins_with(".") \
else (base_path + "." + ext)
var try_paths:Array = extensions.map(_append_ext)
for path:String in try_paths:
if not file_exists(path): continue
return load_supported(path)
push_error("Could not find any file for '%s'.%s!" % [base_path, extensions])
return null
## [param parse] Callable(buffer:PackedByteArray)->Variant
func load_and_parse(path:String, parse:Callable)->Variant:
var abs_path:String = get_absolute_path(path)

View File

@ -30,7 +30,7 @@ static func load_mp3(buffer:PackedByteArray)->AudioStreamMP3:
static func load_ogg(buffer:PackedByteArray)->AudioStreamOggVorbis:
var sfx := AudioStreamOggVorbis.new()
sfx.data = buffer
sfx.load_from_buffer(buffer)
return sfx
static func load_txt(buffer:PackedByteArray)->String: