@@ -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 ( || {
@@ -34,24 +35,27 @@ pub static MODRINTH_API: LazyLock<ferinth::Ferinth<()>> = LazyLock::new(|| {
3435 )
3536} ) ;
3637
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+ } ) ;
3944
4045/// 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.
4346pub fn get_minecraft_dir ( ) -> PathBuf {
44- #[ cfg( target_os = "windows" ) ]
45- return HOME . join ( "AppData" ) . join ( "Roaming" ) . join ( ".minecraft" ) ;
46-
4747 #[ 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+ }
5559}
5660
5761/// Read `source` and return the data as a string
0 commit comments