Skip to content

Commit b22f16a

Browse files
committed
Windows updates
1 parent dd18811 commit b22f16a

File tree

7 files changed

+62
-103
lines changed

7 files changed

+62
-103
lines changed

Cargo.toml

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ profiling = { version = "1.0.17", default-features = false }
2525
puffin = {optional = true, version = "0.19.1"}
2626
puffin_http = {optional = true, version = "0.16.1"}
2727
icu = {git = "https://github.com/unicode-org/icu4x", rev = "4d2b015"}
28-
notify = "6.1"
28+
notify = "8"
2929
smallvec = "1.15"
3030
bevy_device_lang = "0.6"
3131
fuzzy-matcher = "0.3"
@@ -41,24 +41,24 @@ egui = "0.33"
4141
egui_extras = { version = "0.33", features = ["all_loaders"] }
4242
open = "5.3"
4343
walkdir = "2"
44-
sysinfo = "0.33"
44+
sysinfo = "0.37"
4545
directories = "6"
4646
image = { version = "0.25", features = ["jpeg", "png"] }
4747
rand = "0.8"
4848
anyhow = "1"
4949
egui-notify = "0.21"
5050
once_cell = "1"
5151
crossbeam = "0.8"
52-
egui_dock = "0.17"
52+
egui_dock = "0.18"
5353
trash = "5.2"
5454
arboard = "3.4.1"
5555
embed_plist = "1.2"
56-
rayon = "1.10"
56+
rayon = "1.11"
5757
rmp-serde = "1.3.0"
5858
bincode = "=2.0.1"
5959

6060
[target.'cfg(windows)'.dependencies]
61-
windows = { version = "0.59", features = [
61+
windows = { version = "0.62", features = [
6262
"Win32_UI_Shell",
6363
"Win32_Storage_FileSystem",
6464
"Win32_System_Registry",
@@ -68,7 +68,7 @@ windows = { version = "0.59", features = [
6868

6969
[build-dependencies]
7070
anyhow = "1.0"
71-
winresource = "0.1.19"
71+
winresource = "0.1"
7272

7373
[lints.rust]
7474
unsafe_code = "deny"
@@ -95,5 +95,3 @@ osx_url_schemes = ["io.github.leinnan.dirfleet"]
9595
short_description = "File Manager"
9696
long_description = "File Manager built with egui in Rust"
9797

98-
[patch.crates-io]
99-
egui_dock = {git = "https://github.com/Avarel/egui_dock.git", branch = "egui_0.33"}

src/app/database.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
use crate::data::files::{DirContent, DirEntry};
22
use bincode::config;
33
use directories::ProjectDirs;
4-
use std::{os::unix::ffi::OsStrExt, path::Path, sync::LazyLock, thread};
4+
use std::{path::Path, sync::LazyLock, thread};
55

66
pub static SLED_DIRS: LazyLock<sled::Db> = LazyLock::new(|| {
7-
let path = ProjectDirs::from("com", "Crayen", "Files").expect("");
7+
let path = ProjectDirs::from("com", "Crayen", "Files2").expect("");
88
if !path.data_dir().exists() {
99
std::fs::create_dir_all(path.data_dir()).expect("Failed to create data directory");
1010
}
@@ -16,10 +16,12 @@ pub fn read_dir(dir: &Path, entries: &mut Vec<DirEntry>) {
1616
#[cfg(feature = "profiling")]
1717
puffin::profile_scope!("lwa_fm::dir_handling::db_read");
1818
let config = config::standard();
19-
let path = dir.as_os_str().as_bytes().to_vec();
19+
let path = dir.as_os_str().as_encoded_bytes().to_vec();
2020
if let Ok(Some(data)) = SLED_DIRS.get(&path) {
21+
#[cfg(feature = "profiling")]
2122
puffin::profile_scope!("lwa_fm::dir_handling::db_read::deserialize");
2223
if let Ok((meta, _)) = bincode::decode_from_slice::<DirContent, _>(&data[..], config) {
24+
#[cfg(feature = "profiling")]
2325
puffin::profile_scope!("lwa_fm::dir_handling::db_read::deserialize::extend");
2426
meta.populate(entries);
2527
return;

src/app/dir_handling.rs

Lines changed: 35 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use std::{
77

88
use icu::collator::CollatorBorrowed;
99
use rayon::{
10-
iter::{IntoParallelRefMutIterator, ParallelBridge, ParallelExtend, ParallelIterator},
10+
iter::{ParallelBridge, ParallelExtend, ParallelIterator},
1111
slice::ParallelSliceMut,
1212
};
1313

@@ -125,63 +125,6 @@ impl TabData {
125125
// }
126126
}
127127

128-
#[allow(dead_code)]
129-
fn read_dir_filter(&mut self) {
130-
let case_sensitive = self
131-
.search
132-
.as_ref()
133-
.is_some_and(|search| search.case_sensitive);
134-
let search = self
135-
.search
136-
.as_ref()
137-
.map(|search| search.value.as_str())
138-
.unwrap_or_default();
139-
let search_len = search.len();
140-
let collator = build_collator(case_sensitive);
141-
let directories: &[PathBuf] = match &self.current_path {
142-
CurrentPath::None => &[],
143-
CurrentPath::One(path_buf) => std::slice::from_ref(path_buf),
144-
CurrentPath::Multiple(path_bufs) => path_bufs.as_slice(),
145-
};
146-
147-
let depth = self.search.as_ref().map_or(1, |search| search.depth);
148-
self.list = directories
149-
.iter()
150-
.flat_map(|d| {
151-
walkdir::WalkDir::new(d)
152-
.follow_links(true)
153-
.max_depth(depth)
154-
.into_iter()
155-
.flatten()
156-
.skip(1)
157-
.filter_map(|e| {
158-
let s = e.file_name().to_string_lossy();
159-
if !self.show_hidden && (s.starts_with('.') || s.starts_with('$')) {
160-
return None;
161-
}
162-
if search_len > s.len() {
163-
return None;
164-
}
165-
let chars = s.as_bytes();
166-
let mut found = false;
167-
for i in 0..=(s.len() - search_len) {
168-
if collator.compare_utf8(search.as_bytes(), &chars[i..i + search_len])
169-
== Ordering::Equal
170-
{
171-
found = true;
172-
break;
173-
}
174-
}
175-
if !found {
176-
return None;
177-
}
178-
e.try_into().ok()
179-
})
180-
.collect::<Vec<crate::data::files::DirEntry>>()
181-
})
182-
.collect();
183-
}
184-
185128
// pub fn get_visible_entries(&self) -> impl Iterator<Item = &DirEntry> {
186129
// self.visible_entries.iter().map(|&idx| &self.list[idx])
187130
// }
@@ -205,34 +148,40 @@ impl TabData {
205148
let search_len = search.len();
206149
let collator = build_collator(case_sensitive);
207150
for (i, entry) in self.list.iter().enumerate() {
208-
let mut visible = true;
209151
if !self.show_hidden {
210152
let name = entry.get_splitted_path().1;
211153
if name.starts_with(".") || name.starts_with("$") {
212-
visible = false;
154+
continue;
213155
}
214156
}
215157
if is_searching {
216158
let name = entry.get_splitted_path().1;
217159
if search_len > name.len() {
218-
visible = false;
219-
} else {
220-
let chars = name.as_bytes();
221-
let mut found = false;
222-
for i in 0..=(name.len() - search_len) {
223-
if collator.compare_utf8(search.as_bytes(), &chars[i..i + search_len])
224-
== Ordering::Equal
225-
{
226-
found = true;
227-
break;
228-
}
160+
continue;
161+
}
162+
let chars = name.as_bytes();
163+
let mut found = false;
164+
for i in 0..=(name.len() - search_len) {
165+
if collator.compare_utf8(search.as_bytes(), &chars[i..i + search_len])
166+
== Ordering::Equal
167+
{
168+
found = true;
169+
log::error!(
170+
"MATCH: {}",
171+
name[i..i + search_len].escape_debug().to_string()
172+
);
173+
break;
174+
}
175+
}
176+
if !found {
177+
if name.contains(search) {
178+
log::error!("WTF: {}", name);
179+
} else {
180+
continue;
229181
}
230-
visible &= found;
231182
}
232183
}
233-
if visible {
234-
self.visible_entries.push(i);
235-
}
184+
self.visible_entries.push(i);
236185
}
237186
}
238187

@@ -267,8 +216,18 @@ impl TabData {
267216
}
268217
CurrentPath::Multiple(path_bufs) => path_bufs.as_slice(),
269218
};
270-
219+
let depth = self.search.as_ref().map_or(1, |search| search.depth);
220+
eprintln!("DEPTH: {}", depth);
271221
for d in directories {
222+
self.list.extend(
223+
walkdir::WalkDir::new(d)
224+
.follow_links(true)
225+
.max_depth(depth)
226+
.into_iter()
227+
.flatten()
228+
.skip(1)
229+
.filter_map(|e| e.try_into().ok()),
230+
);
272231
let paths = {
273232
#[cfg(feature = "profiling")]
274233
puffin::profile_scope!("lwa_fm::dir_handling::read_dir::with_hidden::dir");
@@ -285,8 +244,6 @@ impl TabData {
285244
e.try_into().ok()
286245
}));
287246
}
288-
289-
self.list.par_iter_mut().for_each(|e| e.read_metadata());
290247
}
291248

292249
pub fn sort_entries(&mut self, sort_settings: &DirectoryViewSettings) {

src/app/top_bottom.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,7 @@ impl App {
263263
ui.toggle_value(&mut search_visible, "🔍")
264264
.on_hover_text("Search");
265265
let mut search_changed = is_searching != search_visible;
266+
let mut search_target_changed = false;
266267
if let Some(search) = &mut current_tab.search {
267268
search_changed |= ui
268269
.toggle_value(&mut search.case_sensitive, "🇨")
@@ -273,7 +274,7 @@ impl App {
273274
.hint_text("Search"),
274275
);
275276
search_changed |= search_input.changed();
276-
search_changed |= ui
277+
search_target_changed |= ui
277278
.add(
278279
egui::Slider::new(&mut search.depth, 1..=7)
279280
.trailing_fill(true)
@@ -313,7 +314,9 @@ impl App {
313314
if search_visible != is_searching {
314315
current_tab.toggle_search(ui.ctx());
315316
}
316-
if search_changed {
317+
if search_target_changed {
318+
TabAction::RequestFilesRefresh.schedule_tab(current_tab.id);
319+
} else if search_changed {
317320
TabAction::FilterChanged.schedule_tab(current_tab.id);
318321
}
319322
ui.spacing_mut().item_spacing = spacing;

src/data/files.rs

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
11
use crate::{
22
app::dir_handling::COLLATER,
33
data::time::{ElapsedTime, TimestampSeconds},
4+
helper::PathHelper,
45
};
56
use bincode::{Decode, Encode};
67
use rayon::iter::{IntoParallelRefIterator, ParallelBridge, ParallelExtend, ParallelIterator};
78
use serde::{Deserialize, Serialize};
8-
use std::{
9-
cmp::Ordering,
10-
fs::FileType,
11-
path::{Path, PathBuf},
12-
};
9+
use std::{cmp::Ordering, fs::FileType, path::Path};
1310

1411
#[derive(
1512
Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Deserialize, Serialize, Decode, Encode,
@@ -77,7 +74,7 @@ impl SortKey {
7774

7875
#[derive(Debug, Clone, Serialize, Deserialize, Decode, Encode)]
7976
pub struct DirContent {
80-
pub path: PathBuf,
77+
pub path: String,
8178
pub entries: Vec<DirEntryData>,
8279
}
8380

@@ -94,23 +91,24 @@ impl DirContent {
9491
let entries: Vec<DirEntryData> = paths
9592
.par_bridge()
9693
.filter_map(|e| {
94+
#[cfg(feature = "profiling")]
9795
puffin::profile_scope!("lwa_fm::dir_handling::db_read::db_mapping::entry");
9896
let e = e.ok()?;
9997
e.try_into().ok()
10098
})
10199
.collect();
102100
Some(Self {
103-
path: dir.into(),
101+
path: dir.to_full_path_string(),
104102
entries,
105103
})
106104
}
107105

108106
#[inline]
109107
pub fn populate(&self, entries: &mut Vec<DirEntry>) {
110-
let file_name_index = self.path.as_os_str().len() + 1;
108+
let file_name_index = self.path.len() + 1;
111109
entries.par_extend(self.entries.par_iter().map(|e| DirEntry {
112110
meta: e.meta,
113-
path: format!("{}/{}", self.path.display(), &e.file_name),
111+
path: format!("{}{}{}", self.path, std::path::MAIN_SEPARATOR, &e.file_name),
114112
file_name_index,
115113
sort_key: e.sort_key,
116114
}));
@@ -265,7 +263,7 @@ impl TryFrom<std::fs::DirEntry> for DirEntry {
265263
let path: String = {
266264
#[cfg(feature = "profiling")]
267265
puffin::profile_scope!("lwa_fm::dir_handling::conversion::from_std::string");
268-
value.path().to_string_lossy().to_string()
266+
value.path().to_full_path_string()
269267
};
270268
let file_name_index = path.len() - value.file_name().len();
271269
let sort_key = SortKey::new_path(
@@ -292,7 +290,7 @@ impl TryFrom<walkdir::DirEntry> for DirEntry {
292290
return Err(());
293291
};
294292
let meta: DirEntryMetaData = meta.into();
295-
let path = value.path().to_string_lossy().to_string();
293+
let path = value.path().to_full_path_string();
296294
let file_name_index = path.len() - value.file_name().len();
297295
// let mut sort_key = SmallVec::<[u8; 40]>::new();
298296
// let _ =

src/watcher.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ impl DirectoryWatchers {
6969
if let Some(receiver) = &self.receivers {
7070
if let Ok(watcher) = receiver.try_recv() {
7171
if let Some(path) = watcher.current_path.as_ref() {
72-
self.watchers.insert(path.to_path_buf(), watcher);
72+
self.watchers.insert(path.clone(), watcher);
7373
}
7474
remove = true;
7575
}

src/windows_tools.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ pub fn open_properties(path: impl AsRef<OsStr>) {
4444
// Open the properties window
4545
#[allow(unsafe_code)]
4646
unsafe {
47+
#[allow(clippy::borrow_as_ptr)]
4748
match ShellExecuteExW(&mut sei) {
4849
Ok(()) => {}
4950
Err(e) => eprintln!("Failed to open properties window: {e:?}"),

0 commit comments

Comments
 (0)