@@ -9,6 +9,7 @@ pub mod version_ext;
9
9
pub use add:: add;
10
10
pub use scan:: scan;
11
11
12
+ use directories:: { BaseDirs , ProjectDirs } ;
12
13
use std:: { path:: PathBuf , sync:: LazyLock } ;
13
14
14
15
pub static GITHUB_API : LazyLock < octocrab:: Octocrab > = LazyLock :: new ( || {
@@ -34,24 +35,27 @@ pub static MODRINTH_API: LazyLock<ferinth::Ferinth<()>> = LazyLock::new(|| {
34
35
)
35
36
} ) ;
36
37
37
- pub static HOME : LazyLock < PathBuf > =
38
- LazyLock :: new ( || home:: home_dir ( ) . expect ( "Could not get user's home directory" ) ) ;
38
+ pub static BASE_DIRS : LazyLock < BaseDirs > =
39
+ LazyLock :: new ( || BaseDirs :: new ( ) . expect ( "Could not get OS specific directories" ) ) ;
40
+
41
+ pub static PROJECT_DIRS : LazyLock < ProjectDirs > = LazyLock :: new ( || {
42
+ ProjectDirs :: from ( "" , "" , "ferium" ) . expect ( "Could not get OS specific directories" )
43
+ } ) ;
39
44
40
45
/// Gets the default Minecraft instance directory based on the current compilation `target_os`
41
- ///
42
- /// If the `target_os` doesn't match `"macos"`, `"linux"`, or `"windows"`, this function will not compile.
43
46
pub fn get_minecraft_dir ( ) -> PathBuf {
44
- #[ cfg( target_os = "windows" ) ]
45
- return HOME . join ( "AppData" ) . join ( "Roaming" ) . join ( ".minecraft" ) ;
46
-
47
47
#[ cfg( target_os = "macos" ) ]
48
- return HOME
49
- . join ( "Library" )
50
- . join ( "Application Support" )
51
- . join ( "minecraft" ) ;
52
-
53
- #[ cfg( target_os = "linux" ) ]
54
- return HOME . join ( ".minecraft" ) ;
48
+ {
49
+ BASE_DIRS . data_dir ( ) . join ( "minecraft" )
50
+ }
51
+ #[ cfg( target_os = "windows" ) ]
52
+ {
53
+ BASE_DIRS . data_dir ( ) . join ( ".minecraft" )
54
+ }
55
+ #[ cfg( not( any( target_os = "macos" , target_os = "windows" ) ) ) ]
56
+ {
57
+ BASE_DIRS . home_dir ( ) . join ( ".minecraft" )
58
+ }
55
59
}
56
60
57
61
/// Read `source` and return the data as a string
0 commit comments