From 15efef34c10ea15590896c7345cc303a897f759a Mon Sep 17 00:00:00 2001 From: NotArme Date: Mon, 25 Nov 2024 23:42:56 -0300 Subject: [PATCH 1/2] Make sure that directory exists before accessing the user library --- material_maker/tools/library_manager/library.gd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/material_maker/tools/library_manager/library.gd b/material_maker/tools/library_manager/library.gd index 3427c3ee9..88e98f5bb 100644 --- a/material_maker/tools/library_manager/library.gd +++ b/material_maker/tools/library_manager/library.gd @@ -108,7 +108,7 @@ func get_sections() -> Array: return Array(sections) func save_library() -> void: - DirAccess.open("res://").make_dir_recursive(library_path.get_base_dir()) + DirAccess.make_dir_recursive_absolute(library_path.get_base_dir()) var file : FileAccess = FileAccess.open(library_path, FileAccess.WRITE) if file != null: file.store_string(JSON.stringify({name=library_name, lib=library_items}, "\t", true)) From 7d8533b3b2cee527a6ef00ebfff8daa14bd4a4c3 Mon Sep 17 00:00:00 2001 From: NotArme Date: Tue, 26 Nov 2024 00:14:19 -0300 Subject: [PATCH 2/2] Creating 'user://library' dir on startup so files can be saved --- material_maker/tools/library_manager/library_manager.gd | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/material_maker/tools/library_manager/library_manager.gd b/material_maker/tools/library_manager/library_manager.gd index 8591c16e8..da3c24a70 100644 --- a/material_maker/tools/library_manager/library_manager.gd +++ b/material_maker/tools/library_manager/library_manager.gd @@ -40,7 +40,7 @@ func _ready(): func _exit_tree(): if item_usage_file == "": return - DirAccess.open("res://").make_dir_recursive(item_usage_file.get_base_dir()) + DirAccess.make_dir_recursive_absolute(item_usage_file.get_base_dir()) var file = FileAccess.open(item_usage_file, FileAccess.WRITE) if file != null: file.store_string(JSON.stringify(item_usage, "\t", true)) @@ -55,6 +55,7 @@ func init_libraries() -> void: add_child(library) library.generate_node_sections(node_sections) library = LIBRARY.new() + DirAccess.make_dir_recursive_absolute(user_lib.get_base_dir()) if library.load_library(user_lib): if library.library_name == "": library.library_name = user_lib_name