1
1
use crate :: structs:: Instance ;
2
+ use directories:: { BaseDirs , UserDirs } ;
2
3
use regex:: Regex ;
3
4
use std:: io:: Read ;
4
- use directories:: { BaseDirs , UserDirs } ;
5
5
6
6
pub mod progress {
7
7
use indicatif:: { ProgressBar , ProgressStyle } ;
@@ -83,7 +83,7 @@ pub fn get_instance_paths() -> Vec<Instance> {
83
83
let bsm_config_file = std:: fs:: File :: open ( bsm_config_path) . unwrap ( ) ;
84
84
let bsm_config: serde_json:: Value = serde_json:: from_reader ( bsm_config_file) . unwrap ( ) ;
85
85
86
- if bsm_config[ "installation_folder " ] . as_str ( ) . is_none ( ) {
86
+ if bsm_config[ "installation-folder " ] . as_str ( ) . is_none ( ) {
87
87
let bs_manager = documents_dir. join ( "BSManager" ) . join ( "BSInstances" ) ;
88
88
89
89
for entry in std:: fs:: read_dir ( bs_manager) . unwrap ( ) {
@@ -94,7 +94,24 @@ pub fn get_instance_paths() -> Vec<Instance> {
94
94
instances. push ( Instance {
95
95
name : path. file_name ( ) . unwrap ( ) . to_str ( ) . unwrap ( ) . to_string ( ) ,
96
96
game_version : get_game_version ( path. to_str ( ) . unwrap ( ) . to_string ( ) ) ,
97
- path
97
+ path,
98
+ } ) ;
99
+ }
100
+ }
101
+ } else {
102
+ let base_path = bsm_config[ "installation-folder" ] . as_str ( ) . unwrap ( ) ;
103
+ let mut bs_manager = std:: path:: Path :: new ( base_path) . join ( "BSManager" ) ;
104
+ bs_manager. push ( "BSInstances" ) ;
105
+
106
+ for entry in std:: fs:: read_dir ( base_path) . unwrap ( ) {
107
+ let entry = entry. unwrap ( ) ;
108
+ let path = entry. path ( ) ;
109
+
110
+ if path. is_dir ( ) {
111
+ instances. push ( Instance {
112
+ name : path. file_name ( ) . unwrap ( ) . to_str ( ) . unwrap ( ) . to_string ( ) ,
113
+ game_version : get_game_version ( path. to_str ( ) . unwrap ( ) . to_string ( ) ) ,
114
+ path,
98
115
} ) ;
99
116
}
100
117
}
0 commit comments