@@ -5,17 +5,24 @@ use std::{
55 process:: exit,
66} ;
77
8+ use crate :: app:: { DEFAULT_WINDOW_HEIGHT , WINDOW_WIDTH } ;
89use global_hotkey:: hotkey:: Code ;
910use iced:: { futures:: io:: Window , widget:: image:: Handle } ;
1011use icns:: IconFamily ;
1112use image:: RgbaImage ;
1213use rayon:: iter:: { IntoParallelIterator , ParallelIterator } ;
14+
15+ #[ cfg( target_os = "windows" ) ]
1316use windows:: Win32 :: {
1417 Graphics :: Gdi :: MonitorFromPoint ,
1518 UI :: WindowsAndMessaging :: { GetCursor , GetCursorPos } ,
1619} ;
1720
1821use crate :: { app:: App , commands:: Function } ;
22+ #[ cfg( target_os = "macos" ) ]
23+ use objc2_app_kit:: NSWorkspace ;
24+ #[ cfg( target_os = "macos" ) ]
25+ use objc2_foundation:: NSURL ;
1926
2027const ERR_LOG_PATH : & str = "/tmp/rustscan-err.log" ;
2128
@@ -307,7 +314,7 @@ pub fn get_config_file_path() -> String {
307314 let file_path = if cfg ! ( target_os = "windows" ) {
308315 home + "\\ rustcast\\ config.toml"
309316 } else {
310- home + "/.rustcast/config.toml"
317+ home + "/.config/ rustcast/config.toml"
311318 } ;
312319
313320 return file_path;
@@ -327,22 +334,18 @@ pub fn create_config_file_if_not_exists(
327334 file_path : & str ,
328335 config : & Config ,
329336) -> Result < ( ) , std:: io:: Error > {
330- if std:: path:: Path :: new ( & get_config_file_path ( ) ) . exists ( ) {
331- return Ok ( ( ) ) ;
332- }
333-
334- #[ cfg( target_os = "windows" ) ]
335- {
336- use std:: path:: Path ;
337- let path = Path :: new ( & file_path) ;
338- if let Some ( parent) = path. parent ( ) {
339- std:: fs:: create_dir_all ( parent) . unwrap ( ) ;
337+ // check if file exists
338+ if let Ok ( exists) = std:: fs:: metadata ( & file_path) {
339+ if exists. is_file ( ) {
340+ return Ok ( ( ) ) ;
340341 }
341342 }
342- #[ cfg( target_os = "macos" ) ]
343- {
344- std:: fs:: create_dir_all ( & file_path) . unwrap ( ) ;
343+
344+ let path = Path :: new ( & file_path) ;
345+ if let Some ( parent) = path. parent ( ) {
346+ std:: fs:: create_dir_all ( parent) . unwrap ( ) ;
345347 }
348+
346349 std:: fs:: write (
347350 & file_path,
348351 toml:: to_string ( & config) . unwrap_or_else ( |x| x. to_string ( ) ) ,
@@ -378,7 +381,7 @@ pub fn open_application(path: &String) {
378381 }
379382}
380383
381- use crate :: app :: { DEFAULT_WINDOW_HEIGHT , WINDOW_WIDTH } ;
384+ # [ cfg ( target_os = "windows" ) ]
382385pub fn open_on_focused_monitor ( ) -> iced:: Point {
383386 use windows:: Win32 :: Foundation :: POINT ;
384387 use windows:: Win32 :: Graphics :: Gdi :: {
0 commit comments