Connect applications to schemes, filetypes, and more on macOS (more to come)
2
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge pull request #39 from amusingimpala75/main

authored by

Miles Wirht and committed by
GitHub
eed1108f 62905290

+13 -11
+13 -11
infat-lib/src/macos/workspace.rs
··· 134 134 pub fn find_applications() -> Result<Vec<PathBuf>> { 135 135 debug!("Searching for applications in standard directories"); 136 136 137 - let search_paths = [ 138 - "/Applications", 139 - "/System/Applications", 140 - "/System/Library/CoreServices/Applications", 141 - &format!("{}/Applications", std::env::var("HOME").unwrap_or_default()), 137 + let mut search_paths = vec![ 138 + Path::new("/Applications").to_path_buf(), 139 + Path::new("/System/Applications").to_path_buf(), 140 + Path::new("/System/Library/CoreServices/Applications").to_path_buf(), 141 + Path::new(&std::env::var("HOME").unwrap_or_default()).join("Applications") 142 142 ]; 143 143 144 144 let mut apps = Vec::new(); 145 145 146 - for search_path in &search_paths { 147 - let path = Path::new(search_path); 146 + while search_paths.len() > 0 { 147 + let path = search_paths.pop().unwrap(); 148 148 if !path.exists() { 149 - debug!("Skipping non-existent path: {}", search_path); 149 + debug!("Skipping non-existent path: {}", path.to_str().unwrap()); 150 150 continue; 151 151 } 152 152 153 - match std::fs::read_dir(path) { 153 + match std::fs::read_dir(&path) { 154 154 Ok(entries) => { 155 155 let mut found_count = 0; 156 156 for entry in entries.flatten() { ··· 169 169 if resolved_path.extension().is_some_and(|ext| ext == "app") { 170 170 apps.push(entry_path); 171 171 found_count += 1; 172 + } else if resolved_path.is_dir() { 173 + search_paths.push(resolved_path); 172 174 } 173 175 } 174 - debug!("Found {} apps in {}", found_count, search_path); 176 + debug!("Found {} apps in {}", found_count, path.to_str().unwrap()); 175 177 } 176 178 Err(e) => { 177 - debug!("Could not read directory {}: {}", search_path, e); 179 + debug!("Could not read directory {}: {}", path.to_str().unwrap(), e); 178 180 } 179 181 } 180 182 }