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.

recursive search: use paths instead of raw strs

+10 -11
+10 -11
infat-lib/src/macos/workspace.rs
··· 135 135 debug!("Searching for applications in standard directories"); 136 136 137 137 let mut search_paths = vec![ 138 - "/Applications".to_string(), 139 - "/System/Applications".to_string(), 140 - "/System/Library/CoreServices/Applications".to_string(), 141 - format!("{}/Applications", std::env::var("HOME").unwrap_or_default().to_string()), 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 146 while search_paths.len() > 0 { 147 - let search_path = search_paths.pop().ok_or(InfatError::Generic { message: "Non-empty vector could not pop".to_string(), })?; 148 - let path = Path::new(&search_path); 147 + let path = search_paths.pop().unwrap(); 149 148 if !path.exists() { 150 - debug!("Skipping non-existent path: {}", search_path); 149 + debug!("Skipping non-existent path: {}", path.to_str().unwrap()); 151 150 continue; 152 151 } 153 152 154 - match std::fs::read_dir(path) { 153 + match std::fs::read_dir(&path) { 155 154 Ok(entries) => { 156 155 let mut found_count = 0; 157 156 for entry in entries.flatten() { ··· 171 170 apps.push(entry_path); 172 171 found_count += 1; 173 172 } else if resolved_path.is_dir() { 174 - search_paths.push(resolved_path.to_str().expect("Invalid path UTF-8").to_string()); 173 + search_paths.push(resolved_path); 175 174 } 176 175 } 177 - debug!("Found {} apps in {}", found_count, search_path); 176 + debug!("Found {} apps in {}", found_count, path.to_str().unwrap()); 178 177 } 179 178 Err(e) => { 180 - debug!("Could not read directory {}: {}", search_path, e); 179 + debug!("Could not read directory {}: {}", path.to_str().unwrap(), e); 181 180 } 182 181 } 183 182 }