From d4f62da6f52268ea8bda5a77137a8af28644c87d Mon Sep 17 00:00:00 2001 From: Cyril Levis Date: Sat, 25 Dec 2021 18:47:15 +0100 Subject: [PATCH] feat: recurse deeper in applications folder max recursion 2 levels --- Cargo.lock | 30 ++++++++++++++++++++++++++++++ Cargo.toml | 1 + src/desktop.rs | 4 ++-- 3 files changed, 33 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 96bd23d..cd88c52 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -520,6 +520,15 @@ version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e" +[[package]] +name = "same-file" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" +dependencies = [ + "winapi-util", +] + [[package]] name = "serde" version = "1.0.123" @@ -663,6 +672,17 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" +[[package]] +name = "walkdir" +version = "2.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "808cf2735cd4b6866113f648b791c6adc5714537bc222d9347bb203386ffda56" +dependencies = [ + "same-file", + "winapi", + "winapi-util", +] + [[package]] name = "wasi" version = "0.10.0+wasi-snapshot-preview1" @@ -744,6 +764,15 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" +[[package]] +name = "winapi-util" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" +dependencies = [ + "winapi", +] + [[package]] name = "winapi-x86_64-pc-windows-gnu" version = "0.4.0" @@ -776,6 +805,7 @@ dependencies = [ "shlex", "timerfd", "unicode-segmentation", + "walkdir", "wayland-client", "wayland-protocols", ] diff --git a/Cargo.toml b/Cargo.toml index c3fc985..352e88d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -37,6 +37,7 @@ rcalc_lib = "0.9" rust-ini = "0.14" shlex = "0.1" timerfd = "1.0.0" +walkdir = "2.3.2" serde = { version = "1.0", features = ["derive"] } serde_json = { version = "1.0", optional = true } diff --git a/src/desktop.rs b/src/desktop.rs index 2f8e822..22bda1f 100644 --- a/src/desktop.rs +++ b/src/desktop.rs @@ -3,9 +3,9 @@ use ini::{Ini, ParseOption}; use std::cmp::Ordering; use std::env; use std::error::Error; -use std::fs; use std::io::Error as io_error; use std::io::ErrorKind; +use walkdir::WalkDir; #[derive(Clone, Debug, Eq, Hash)] pub struct Desktop { @@ -56,7 +56,7 @@ impl Desktop { fn parse_dir(d: &str) -> Result, Box> { let mut files: Vec = Vec::with_capacity(16); - for entry in fs::read_dir(d)? { + for entry in WalkDir::new(d) { let entry = entry?; let path = entry.path();