94
94
mod utils;
95
95
use utils:: * ;
96
96
97
- #[ cfg( feature = "xdg" ) ]
98
- use etcetera:: app_strategy:: choose_app_strategy;
99
- #[ cfg( not( feature = "xdg" ) ) ]
100
- use etcetera:: app_strategy:: choose_native_strategy;
101
- use etcetera:: { AppStrategy , AppStrategyArgs } ;
97
+ use etcetera:: { AppStrategy , AppStrategyArgs , app_strategy:: choose_app_strategy} ;
102
98
use serde:: { Serialize , de:: DeserializeOwned } ;
103
99
use std:: fs:: { self , File , OpenOptions , Permissions } ;
104
100
use std:: io:: { ErrorKind :: NotFound , Write } ;
@@ -473,31 +469,14 @@ pub fn get_configuration_file_path<'a>(
473
469
config_name : impl Into < Option < & ' a str > > ,
474
470
) -> Result < PathBuf , ConfyError > {
475
471
let config_name = config_name. into ( ) . unwrap_or ( "default-config" ) ;
476
- let project;
477
-
478
- #[ cfg( not( feature = "xdg" ) ) ]
479
- {
480
- project = choose_native_strategy ( AppStrategyArgs {
481
- top_level_domain : "rs" . to_string ( ) ,
482
- author : "" . to_string ( ) ,
483
- app_name : app_name. to_string ( ) ,
484
- } )
485
- . map_err ( |e| {
486
- ConfyError :: BadConfigDirectory ( format ! ( "could not determine home directory path: {e}" ) )
487
- } ) ?;
488
- }
489
-
490
- #[ cfg( feature = "xdg" ) ]
491
- {
492
- project = choose_app_strategy ( AppStrategyArgs {
493
- top_level_domain : "rs" . to_string ( ) ,
494
- author : "" . to_string ( ) ,
495
- app_name : app_name. to_string ( ) ,
496
- } )
497
- . map_err ( |e| {
498
- ConfyError :: BadConfigDirectory ( format ! ( "could not determine home directory path: {e}" ) )
499
- } ) ?;
500
- }
472
+ let project = choose_app_strategy ( AppStrategyArgs {
473
+ top_level_domain : "rs" . to_string ( ) ,
474
+ author : "" . to_string ( ) ,
475
+ app_name : app_name. to_string ( ) ,
476
+ } )
477
+ . map_err ( |e| {
478
+ ConfyError :: BadConfigDirectory ( format ! ( "could not determine home directory path: {e}" ) )
479
+ } ) ?;
501
480
502
481
let config_dir_str = get_configuration_directory_str ( & project) ?;
503
482
@@ -509,13 +488,7 @@ pub fn get_configuration_file_path<'a>(
509
488
}
510
489
511
490
fn get_configuration_directory_str ( project : & impl AppStrategy ) -> Result < String , ConfyError > {
512
- let path = if cfg ! ( feature = "xdg" ) {
513
- project. config_dir ( )
514
- } else {
515
- project. data_dir ( )
516
- } ;
517
-
518
- Ok ( format ! ( "{}" , path. display( ) ) )
491
+ Ok ( project. config_dir ( ) . display ( ) . to_string ( ) )
519
492
}
520
493
521
494
#[ cfg( test) ]
0 commit comments