@@ -267,15 +267,15 @@ func _load_config_file():
267
267
# TODO: behavior for when file is corrupt
268
268
269
269
func _get_credential (key : String ) -> String :
270
- var json : Dictionary = JSONUtils .load_json_file (_get_config_dir () + "/ rh_credentials.json" )
270
+ var json : Dictionary = JSONUtils .load_json_file (_get_config_dir (). path_join ( " rh_credentials.json") )
271
271
if not json .is_empty () and json .has (key ):
272
272
return json [key ]
273
273
return ""
274
274
275
275
func _set_credential (key : String , value : String ):
276
- var json : Dictionary = JSONUtils .load_json_file (_get_config_dir () + "/ rh_credentials.json" )
276
+ var json : Dictionary = JSONUtils .load_json_file (_get_config_dir (). path_join ( " rh_credentials.json") )
277
277
json [key ] = value
278
- JSONUtils .save_json_file (json , _get_config_dir () + "/ rh_credentials.json" )
278
+ JSONUtils .save_json_file (json , _get_config_dir (). path_join ( " rh_credentials.json") )
279
279
280
280
func _on_config_updated (key , old_value , new_value ):
281
281
match key :
@@ -552,7 +552,7 @@ func set_theme_config(key, value):
552
552
func _load_theme_config ():
553
553
_theme_config = {}
554
554
_theme_config_changed = false
555
- var theme_config_path := _get_theme_config_dir () + "/ config.json"
555
+ var theme_config_path := _get_theme_config_dir (). path_join ( " config.json")
556
556
# If the config file doesn't exist, don't try reading it
557
557
if not FileAccess .file_exists (theme_config_path ):
558
558
return
@@ -566,7 +566,7 @@ func _load_theme_config():
566
566
567
567
func save_theme_config ():
568
568
if _theme_config_changed :
569
- var theme_config_path := _get_theme_config_dir () + "/ config.json"
569
+ var theme_config_path := _get_theme_config_dir (). path_join ( " config.json")
570
570
FileUtils .ensure_path (theme_config_path )
571
571
var file := FileAccess .open (theme_config_path , FileAccess .WRITE )
572
572
if not file :
@@ -597,12 +597,12 @@ func _bootstrap_config_dir():
597
597
push_error ("Error when creating directory " + path )
598
598
599
599
# Bootstrap system specific configs
600
- for filename in [
600
+ for filename : String in [
601
601
"rh_emulators.json" ,
602
602
"rh_systems.json" ,
603
603
"_emulator_paths.json"
604
604
]:
605
- var filepath_out := _get_config_dir () + "/" + (filename as String )
605
+ var filepath_out := _get_config_dir (). path_join (filename )
606
606
var file := FileAccess .open (filepath_out , FileAccess .WRITE )
607
607
if not file :
608
608
push_error ("Error when opening file " + filepath_out + " for saving" )
@@ -611,7 +611,7 @@ func _bootstrap_config_dir():
611
611
file .close ()
612
612
613
613
# Bootstrap credentials file
614
- JSONUtils .save_json_file ({}, _get_config_dir () + "/ rh_credentials.json" )
614
+ JSONUtils .save_json_file ({}, _get_config_dir (). path_join ( " rh_credentials.json") )
615
615
616
616
func _save_config ():
617
617
if config .save_config_to_path (_get_config_file ()):
@@ -734,7 +734,7 @@ func _determine_sc_mode():
734
734
if exe_path .ends_with ("MacOS" ) and exe_path .path_join (".." ).simplify_path ().ends_with ("Contents" ):
735
735
exe_path = exe_path .path_join ("../../.." ).simplify_path ()
736
736
737
- if FileAccess .file_exists (exe_path + "/ ._sc_" ) or FileAccess .file_exists (exe_path + "/ _sc_" ):
737
+ if FileAccess .file_exists (exe_path . path_join ( " ._sc_" )) or FileAccess .file_exists (exe_path . path_join ( " _sc_") ):
738
738
_is_sc = true
739
739
740
740
func _get_emulator_path (emulator_name : String , key : String ) -> String :
@@ -759,22 +759,22 @@ func _set_emulator_path(emulator_name: String, key: String, value: String) -> vo
759
759
func _get_config_dir () -> String :
760
760
var path : String
761
761
if _is_sc :
762
- return OS .get_executable_path ().get_base_dir () + "/ config"
762
+ return OS .get_executable_path ().get_base_dir (). path_join ( " config")
763
763
764
764
match FileUtils .get_os_id ():
765
765
FileUtils .OS_ID .WINDOWS :
766
- path = FileUtils .get_home_dir () + "/ RetroHub"
766
+ path = FileUtils .get_home_dir (). path_join ( " RetroHub")
767
767
if RetroHub ._is_dev_env ():
768
768
path += "-Dev"
769
769
return path
770
770
_ :
771
- path = FileUtils .get_home_dir () + "/ .retrohub"
771
+ path = FileUtils .get_home_dir (). path_join ( " .retrohub")
772
772
if RetroHub ._is_dev_env ():
773
773
path += "-dev"
774
774
return path
775
775
776
776
func _get_config_file () -> String :
777
- return _get_config_dir () + "/ rh_config.json"
777
+ return _get_config_dir (). path_join ( " rh_config.json")
778
778
779
779
func _get_systems_file () -> String :
780
780
return "res://base_config/systems.json"
@@ -783,27 +783,27 @@ func _get_emulators_file() -> String:
783
783
return "res://base_config/emulators.json"
784
784
785
785
func _get_emulator_paths_file () -> String :
786
- return _get_config_dir () + "/ _emulator_paths.json"
786
+ return _get_config_dir (). path_join ( " _emulator_paths.json")
787
787
788
788
func _get_custom_systems_file () -> String :
789
- return _get_config_dir () + "/ rh_systems.json"
789
+ return _get_config_dir (). path_join ( " rh_systems.json")
790
790
791
791
func _get_custom_emulators_file () -> String :
792
- return _get_config_dir () + "/ rh_emulators.json"
792
+ return _get_config_dir (). path_join ( " rh_emulators.json")
793
793
794
794
func _get_default_themes_dir () -> String :
795
795
return "res://default_themes"
796
796
797
797
func _get_themes_dir () -> String :
798
- return _get_config_dir () + "/ themes"
798
+ return _get_config_dir (). path_join ( " themes")
799
799
800
800
func _get_theme_config_dir () -> String :
801
- return _get_themes_dir () + "/ config/" + theme_data .id if theme_data else ""
801
+ return _get_themes_dir (). path_join ( " config" ). path_join ( theme_data .id if theme_data else "" )
802
802
803
803
func _get_gamelists_dir () -> String :
804
- return _get_config_dir () + "/ gamelists"
804
+ return _get_config_dir (). path_join ( " gamelists")
805
805
806
806
func _get_gamemedia_dir () -> String :
807
807
if not config .custom_gamemedia_dir .is_empty ():
808
808
return config .custom_gamemedia_dir
809
- return _get_config_dir () + "/ gamemedia"
809
+ return _get_config_dir (). path_join ( " gamemedia")
0 commit comments