@@ -16,7 +16,6 @@ use time::OffsetDateTime;
1616
1717#[ cfg( unix) ]
1818use crate :: RUNTIME_DIR_NAME ;
19- use crate :: TAURI_PRODUCT_NAME ;
2019use crate :: env_var:: {
2120 Q_BUNDLE_METADATA_PATH ,
2221 Q_PARENT ,
@@ -26,6 +25,11 @@ use crate::system_info::{
2625 in_cloudshell,
2726 is_remote,
2827} ;
28+ use crate :: {
29+ BACKUP_DIR_NAME ,
30+ DATA_DIR_NAME ,
31+ TAURI_PRODUCT_NAME ,
32+ } ;
2933
3034macro_rules! utf8_dir {
3135 ( $name: ident, $( $arg: ident: $type: ty) ,* ) => {
@@ -136,21 +140,13 @@ pub fn old_fig_data_dir() -> Result<PathBuf> {
136140
137141/// The q data directory
138142///
139- /// - Linux: `$XDG_DATA_HOME/amazon-q ` or `$HOME/.local/share/amazon-q `
140- /// - MacOS: `$HOME/Library/Application Support/amazon-q `
141- /// - Windows: `%LOCALAPPDATA%\AmazonQ `
143+ /// - Linux: `$XDG_DATA_HOME/{data_dir} ` or `$HOME/.local/share/{data_dir} `
144+ /// - MacOS: `$HOME/Library/Application Support/{data_dir} `
145+ /// - Windows: `%LOCALAPPDATA%\{data_dir} `
142146pub fn fig_data_dir ( ) -> Result < PathBuf > {
143- cfg_if:: cfg_if! {
144- if #[ cfg( unix) ] {
145- Ok ( dirs:: data_local_dir( )
146- . ok_or( DirectoryError :: NoHomeDirectory ) ?
147- . join( "amazon-q" ) )
148- } else if #[ cfg( windows) ] {
149- Ok ( dirs:: data_local_dir( )
150- . ok_or( DirectoryError :: NoHomeDirectory ) ?
151- . join( "AmazonQ" ) )
152- }
153- }
147+ Ok ( dirs:: data_local_dir ( )
148+ . ok_or ( DirectoryError :: NoHomeDirectory ) ?
149+ . join ( DATA_DIR_NAME ) )
154150}
155151
156152pub fn fig_data_dir_ctx ( fs : & impl FsProvider ) -> Result < PathBuf > {
@@ -184,21 +180,13 @@ pub fn local_data_dir<Ctx: FsProvider + EnvProvider + PlatformProvider>(ctx: &Ct
184180
185181/// The q cache directory
186182///
187- /// - Linux: `$XDG_CACHE_HOME/amazon-q ` or `$HOME/.cache/amazon-q `
188- /// - MacOS: `$HOME/Library/Caches/amazon-q `
189- /// - Windows: `%LOCALAPPDATA%\AmazonQ \cache`
183+ /// - Linux: `$XDG_CACHE_HOME/{data_dir} ` or `$HOME/.cache/{data_dir} `
184+ /// - MacOS: `$HOME/Library/Caches/{data_dir} `
185+ /// - Windows: `%LOCALAPPDATA%\{data_dir} \cache`
190186pub fn cache_dir ( ) -> Result < PathBuf > {
191- cfg_if:: cfg_if! {
192- if #[ cfg( unix) ] {
193- Ok ( dirs:: cache_dir( )
194- . ok_or( DirectoryError :: NoHomeDirectory ) ?
195- . join( "amazon-q" ) )
196- } else if #[ cfg( windows) ] {
197- Ok ( dirs:: cache_dir( )
198- . ok_or( DirectoryError :: NoHomeDirectory ) ?
199- . join( "AmazonQ" ) )
200- }
201- }
187+ Ok ( dirs:: cache_dir ( )
188+ . ok_or ( DirectoryError :: NoHomeDirectory ) ?
189+ . join ( DATA_DIR_NAME ) )
202190}
203191
204192/// Get the macos tempdir from the `confstr` function
@@ -246,13 +234,13 @@ pub fn runtime_dir() -> Result<PathBuf> {
246234///
247235/// - Linux: $XDG_RUNTIME_DIR/cwrun
248236/// - MacOS: $TMPDIR/cwrun
249- /// - Windows: %TEMP%\sockets
237+ /// - Windows: %TEMP%\{data_dir}\ sockets
250238pub fn sockets_dir ( ) -> Result < PathBuf > {
251239 cfg_if:: cfg_if! {
252240 if #[ cfg( unix) ] {
253241 Ok ( runtime_dir( ) ?. join( RUNTIME_DIR_NAME ) )
254242 } else if #[ cfg( windows) ] {
255- Ok ( runtime_dir( ) ?. join( "AmazonQ" ) . join( "sockets" ) )
243+ Ok ( runtime_dir( ) ?. join( DATA_DIR_NAME ) . join( "sockets" ) )
256244 }
257245 }
258246}
@@ -303,24 +291,24 @@ pub fn autocomplete_specs_dir() -> Result<PathBuf> {
303291/// The directory to all the fig logs
304292/// - Linux: `/tmp/fig/$USER/logs`
305293/// - MacOS: `$TMPDIR/logs`
306- /// - Windows: `%TEMP%\AmazonQ \logs`
294+ /// - Windows: `%TEMP%\{data_dir} \logs`
307295pub fn logs_dir ( ) -> Result < PathBuf > {
308296 cfg_if:: cfg_if! {
309297 if #[ cfg( unix) ] {
310298 use crate :: CLI_BINARY_NAME ;
311299 Ok ( runtime_dir( ) ?. join( format!( "{CLI_BINARY_NAME}log" ) ) )
312300 } else if #[ cfg( windows) ] {
313- Ok ( std:: env:: temp_dir( ) . join( "AmazonQ" ) . join( "logs" ) )
301+ Ok ( std:: env:: temp_dir( ) . join( DATA_DIR_NAME ) . join( "logs" ) )
314302 }
315303 }
316304}
317305
318306/// The directory where fig places all data-sensitive backups
319307///
320- /// - Linux/MacOS: `$HOME/.amazon-q.dotfiles.bak `
321- /// - Windows: `%USERPROFILE%\.amazon-q.dotfiles.bak `
308+ /// - Linux/MacOS: `$HOME/{backup_dir} `
309+ /// - Windows: `%USERPROFILE%\{backup_dir} `
322310pub fn backups_dir ( ) -> Result < PathBuf > {
323- Ok ( home_dir ( ) ?. join ( ".amazon-q.dotfiles.bak" ) )
311+ Ok ( home_dir ( ) ?. join ( BACKUP_DIR_NAME ) )
324312}
325313
326314/// The directory for time based data-sensitive backups
@@ -397,9 +385,9 @@ pub fn figterm_socket_path(session_id: impl Display) -> Result<PathBuf> {
397385
398386/// The path to the resources directory
399387///
400- /// - MacOS: "/Applications/Amazon Q .app/Contents/Resources"
388+ /// - MacOS: "/Applications/{app_name} .app/Contents/Resources"
401389/// - Linux: "/usr/share/fig"
402- /// - Windows: "%LOCALAPPDATA%\AmazonQ \resources"
390+ /// - Windows: "%LOCALAPPDATA%\{data_dir} \resources"
403391pub fn resources_path ( ) -> Result < PathBuf > {
404392 cfg_if:: cfg_if! {
405393 if #[ cfg( all( unix, not( target_os = "macos" ) ) ) ] {
@@ -433,9 +421,9 @@ pub fn resources_path_ctx<Ctx: EnvProvider + PlatformProvider>(ctx: &Ctx) -> Res
433421
434422/// The path to the fig install manifest
435423///
436- /// - MacOS: "/Applications/Amazon Q .app/Contents/Resources/manifest.json"
424+ /// - MacOS: "/Applications/{app_name} .app/Contents/Resources/manifest.json"
437425/// - Linux: "/usr/share/fig/manifest.json"
438- /// - Windows: "%LOCALAPPDATA%\AmazonQ \resources\bin\manifest.json"
426+ /// - Windows: "%LOCALAPPDATA%\{data_dir} \resources\bin\manifest.json"
439427pub fn manifest_path ( ) -> Result < PathBuf > {
440428 cfg_if:: cfg_if! {
441429 if #[ cfg( unix) ] {
@@ -460,18 +448,18 @@ pub fn bundle_metadata_path<Ctx: EnvProvider + PlatformProvider>(ctx: &Ctx) -> R
460448
461449/// The path to the fig settings file
462450///
463- /// - Linux: `$HOME/.local/share/amazon-q /settings.json`
464- /// - MacOS: `$HOME/Library/Application Support/amazon-q /settings.json`
465- /// - Windows: `%LOCALAPPDATA%\AmazonQ \settings.json`
451+ /// - Linux: `$HOME/.local/share/{data_dir} /settings.json`
452+ /// - MacOS: `$HOME/Library/Application Support/{data_dir} /settings.json`
453+ /// - Windows: `%LOCALAPPDATA%\{data_dir} \settings.json`
466454pub fn settings_path ( ) -> Result < PathBuf > {
467455 Ok ( fig_data_dir ( ) ?. join ( "settings.json" ) )
468456}
469457
470458/// The path to the lock file used to indicate that the app is updating
471459///
472- /// - Linux: `$HOME/.local/share/amazon-q /update.lock`
473- /// - MacOS: `$HOME/Library/Application Support/amazon-q /update.lock`
474- /// - Windows: `%LOCALAPPDATA%\AmazonQ \update.lock`
460+ /// - Linux: `$HOME/.local/share/{data_dir} /update.lock`
461+ /// - MacOS: `$HOME/Library/Application Support/{data_dir} /update.lock`
462+ /// - Windows: `%LOCALAPPDATA%\{data_dir} \update.lock`
475463pub fn update_lock_path ( ctx : & impl FsProvider ) -> Result < PathBuf > {
476464 Ok ( fig_data_dir_ctx ( ctx) ?. join ( "update.lock" ) )
477465}
0 commit comments