9494mod utils;
9595use utils:: * ;
9696
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} ;
10298use serde:: { Serialize , de:: DeserializeOwned } ;
10399use std:: fs:: { self , File , OpenOptions , Permissions } ;
104100use std:: io:: { ErrorKind :: NotFound , Write } ;
@@ -473,31 +469,14 @@ pub fn get_configuration_file_path<'a>(
473469 config_name : impl Into < Option < & ' a str > > ,
474470) -> Result < PathBuf , ConfyError > {
475471 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+ } ) ?;
501480
502481 let config_dir_str = get_configuration_directory_str ( & project) ?;
503482
@@ -509,13 +488,7 @@ pub fn get_configuration_file_path<'a>(
509488}
510489
511490fn 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 ( ) )
519492}
520493
521494#[ cfg( test) ]
0 commit comments