@@ -9,6 +9,7 @@ pub mod version_ext;
99pub use add:: add;
1010pub use scan:: scan;
1111
12+ use directories:: { BaseDirs , ProjectDirs } ;
1213use std:: { path:: PathBuf , sync:: LazyLock } ;
1314
1415pub static GITHUB_API : LazyLock < octocrab:: Octocrab > = LazyLock :: new ( || {
@@ -36,24 +37,27 @@ pub static MODRINTH_API: LazyLock<ferinth::Ferinth> = LazyLock::new(|| {
3637 . expect ( "Could not build Modrinth client" ) // This should never fail since no `authorisation` token was provided
3738} ) ;
3839
39- pub static HOME : LazyLock < PathBuf > =
40- LazyLock :: new ( || home:: home_dir ( ) . expect ( "Could not get user's home directory" ) ) ;
40+ pub static BASE_DIRS : LazyLock < BaseDirs > =
41+ LazyLock :: new ( || BaseDirs :: new ( ) . expect ( "Could not get OS specific directories" ) ) ;
42+
43+ pub static PROJECT_DIRS : LazyLock < ProjectDirs > = LazyLock :: new ( || {
44+ ProjectDirs :: from ( "" , "" , "ferium" ) . expect ( "Could not get OS specific directories" )
45+ } ) ;
4146
4247/// Gets the default Minecraft instance directory based on the current compilation `target_os`
43- ///
44- /// If the `target_os` doesn't match `"macos"`, `"linux"`, or `"windows"`, this function will not compile.
4548pub fn get_minecraft_dir ( ) -> PathBuf {
46- #[ cfg( target_os = "windows" ) ]
47- return HOME . join ( "AppData" ) . join ( "Roaming" ) . join ( ".minecraft" ) ;
48-
4949 #[ cfg( target_os = "macos" ) ]
50- return HOME
51- . join ( "Library" )
52- . join ( "Application Support" )
53- . join ( "minecraft" ) ;
54-
55- #[ cfg( target_os = "linux" ) ]
56- return HOME . join ( ".minecraft" ) ;
50+ {
51+ BASE_DIRS . data_dir ( ) . join ( "minecraft" )
52+ }
53+ #[ cfg( target_os = "windows" ) ]
54+ {
55+ BASE_DIRS . data_dir ( ) . join ( ".minecraft" )
56+ }
57+ #[ cfg( not( any( target_os = "macos" , target_os = "windows" ) ) ) ]
58+ {
59+ BASE_DIRS . home_dir ( ) . join ( ".minecraft" )
60+ }
5761}
5862
5963/// Read `source` and return the data as a string
0 commit comments