19 lines
744 B
GDScript
19 lines
744 B
GDScript
@tool
|
|
extends Node
|
|
func read_text(path: String) -> String:
|
|
return FileAccess.get_file_as_string(path)
|
|
func list_files(path: String) -> Array[String]:
|
|
var result: Array[String] = []
|
|
for file in DirAccess.get_files_at(path): result.append(path+"/"+file)
|
|
for folder in DirAccess.get_directories_at(path): result.append_array(list_files(path+"/"+folder))
|
|
return result
|
|
func write_text(path: String, content: String) -> void:
|
|
var file := FileAccess.open(path,FileAccess.WRITE)
|
|
file.store_string(content)
|
|
|
|
func copy_image(source: String, target: String) -> int:
|
|
var image := Image.load_from_file(source)
|
|
if image == null: return ERR_FILE_NOT_FOUND
|
|
DirAccess.make_dir_recursive_absolute(target.get_base_dir())
|
|
return image.save_png(target)
|