Compare commits

...

3 Commits

Author SHA1 Message Date
cf61dcf39c I dunno fix something. 2024-12-06 18:25:32 -05:00
9681ad0a07 Return string correctly if loading a supported text file. 2024-12-06 18:25:24 -05:00
5069dd65c7 Fix incorrectly loading OGG 2024-12-06 18:25:06 -05:00
3 changed files with 11 additions and 11 deletions

View File

@ -17,8 +17,8 @@ static func create_meta_accessor(file_accessors:Array[VFileAccess])->VFileAccess
var accum:Array[String] = []
accum.assign(
file_accessors.reduce(
(func _merge_files(total:Array[String], current:VFileAccess)->Array[String]:
var res:Array[String] = total.duplicate()
(func _merge_files(total:Array, current:VFileAccess)->Array:
var res:Array = total.duplicate()
for file:String in current.get_files_at(path):
if not file in total:
res.append(file)
@ -171,13 +171,13 @@ static func create_bulk_readonly_zip_access(
vfiler._get_files_at = func(path:String)->Array[String]:
if not path.ends_with("/"): # TODO ensure no // as well because that can be problem.
path += "/" # sorry for the mutation
var accum:Array[String] = []
var accum:Array = []
accum.assign( readers.reduce(
(func _merge_files(total:Array[String], current:ZIPReader)->Array[String]:
var res:Array[String] = total.duplicate()
(func _merge_files(total:Array, current:ZIPReader)->Array:
var res:Array = total.duplicate()
var filtered:Array = []
filtered.assign(current.get_files())
filtered.filter(
filtered = filtered.filter(
func _filter_dir(curpath:String)->bool:
return curpath.begins_with(path))
for file:String in filtered:
@ -186,6 +186,8 @@ static func create_bulk_readonly_zip_access(
if not file in total and not stripped_file.contains("/"):
res.append(file)
return res) ,[]))
return accum
var out_accum:Array[String] = []
out_accum.assign(accum)
return out_accum
return vfiler

2
vfs.gd
View File

@ -94,7 +94,7 @@ func load_supported(path:String, ext_override:String = "")->Variant:
var buffer := get_buffer(path)
var result:Variant = supported_files[ext].call(buffer)
if not is_instance_valid(result):
if not is_instance_valid(result) and result is not String:
push_warning("%s loader tried loading '%s' but received null. Does the file exist?"
% [ext, abs_path])

View File

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