diff options
| author | divens <divens@users.noreply.github.com> | 2026-03-21 19:20:32 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-03-21 19:20:32 +0100 |
| commit | 3fa7744906d5704bdec771c74829841bd06cf7fc (patch) | |
| tree | 6c4f0bd64c2e6087ce069a466cca942f4669f513 /default-plugins/strider/src/file_list_view.rs | |
| parent | Release notes and fixes (#4879) (diff) | |
| download | sl0ppij-3fa7744906d5704bdec771c74829841bd06cf7fc.tar.gz sl0ppij-3fa7744906d5704bdec771c74829841bd06cf7fc.tar.xz sl0ppij-3fa7744906d5704bdec771c74829841bd06cf7fc.zip | |
Add windows support in strider (#4854)
* Add Windows path support to strider plugin
Strider is a WASM plugin where std::path::PathBuf uses Unix semantics,
so Windows backslash paths break parent(), join(), strip_prefix(), etc.
Fix by normalizing all incoming paths to forward slashes at plugin
boundaries and converting back to native backslashes for display. A new
platform.rs module detects the host OS at runtime from the initial_cwd
format and centralizes all platform-aware logic.
Also fix scan_host_folder on the server side: canonicalize
plugin_host_folder so the starts_with security check works on Windows,
where canonicalize() adds the \?\ prefix.
* Add virtual root view for drive and WSL navigation in strider
On Windows, navigating up from a drive root (e.g. C:\) now shows a
"Computer" view listing all available drives and WSL distributions.
Drives are enumerated via GetLogicalDriveStringsW and WSL distros
via `wsl -l -q` (since read_dir on \wsl.localhost fails with OS
error 64/67). Drive letters appear before WSL entries, which are
displayed as "Ubuntu-24.04 (WSL)" etc. On non-Windows platforms,
behavior is unchanged.
* Rename ListHostEntries to ListWindowsVolumes and gate behind FullHdAccess
The old name was misleading — on Unix it just returned `/`, which isn't
"listing host entries." Rename to ListWindowsVolumes to make the
Windows-specific intent explicit, gate behind FullHdAccess permission,
and replace the Unix implementation with a log::error since the command
is not meaningful on non-Windows platforms.
* Replace direct array indexing with .get() in strider platform detection
Use safe accessors and matches! macro instead of direct byte indexing
for bounds-checked access patterns.
---------
Co-authored-by: divens <divens.dev@gmail.com>
Diffstat (limited to 'default-plugins/strider/src/file_list_view.rs')
| -rw-r--r-- | default-plugins/strider/src/file_list_view.rs | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/default-plugins/strider/src/file_list_view.rs b/default-plugins/strider/src/file_list_view.rs index 2226e618..ee620970 100644 --- a/default-plugins/strider/src/file_list_view.rs +++ b/default-plugins/strider/src/file_list_view.rs @@ -1,3 +1,4 @@ +use crate::platform::Platform; use crate::shared::{calculate_list_bounds, render_list_tip}; use crate::state::refresh_directory; use pretty_bytes::converter::convert as pretty_bytes; @@ -12,6 +13,7 @@ pub struct FileListView { pub path_is_dir: bool, pub files: Vec<FsEntry>, pub cursor_hist: HashMap<PathBuf, usize>, + pub platform: Platform, } impl Default for FileListView { @@ -21,14 +23,18 @@ impl Default for FileListView { path: PathBuf::new(), files: Default::default(), cursor_hist: Default::default(), + platform: Platform::default(), } } } impl FileListView { pub fn descend_to_previous_path(&mut self) { + if Platform::is_root(&self.path, self.platform) { + return; + } if let Some(parent) = self.path.parent() { - self.path = parent.to_path_buf(); + self.path = Platform::ensure_drive_root(parent.to_path_buf(), self.platform); } else { self.path = PathBuf::new(); } @@ -65,6 +71,7 @@ impl FileListView { ) { let mut files = vec![]; for (entry, entry_metadata) in paths { + let entry = Platform::normalize(&entry); let entry = self .path .join(entry.strip_prefix("/host").unwrap_or(&entry)); @@ -126,7 +133,7 @@ impl FileListView { .map(|s| pretty_bytes(s as f64)) .unwrap_or("".to_owned()); if entry.is_folder() { - file_or_folder_name.push('/'); + file_or_folder_name.push(self.platform.separator()); } let file_or_folder_name_width = file_or_folder_name.width(); let size_width = size.width(); |
