Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial Windows root navigation #98

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft

Conversation

tehbilly
Copy link

@tehbilly tehbilly commented Feb 9, 2024

This is to address #96

The interface will list all logical drives and present them in a list, allowing you to change to the root of the drive when selected.

I took a very hacky approach just to see viability, I didn't want to add a lot of special casing to different methods out of the gate. Would love some feedback and direction!

Current issues:

  • Doesn't trigger when using .. at the drive root
  • Doesn't identify and filter out non-navigable drives (drives without media)

@mgunyho
Copy link
Owner

mgunyho commented Feb 9, 2024

Hi and thanks for kicking this off! I'll look into it in more detail when I have more time.

At a quick glance, the function for getting the drive letters seems pretty low level, could there be a simple crate that does this for us? Hopefully such a crate would also deal with the non-navigable drives.

As you said, the user should be able to reach the drive letter listing by navigating upwards, so I think we will need something in addition to (or instead of) a windows-specific on_go_to_root.

But this is definitely a good starting point! I don't immediately see anything missing from your approach.

@mgunyho
Copy link
Owner

mgunyho commented Feb 15, 2024

I couldn't find a crate to list the drives safely, but here's a different version using the windows-rs crate and the GetLogicalDriveStringsW function, which is a bit more straightforward IMO:

[dependencies]
windows = { version = "0.52", features = ["Win32_Storage_FileSystem"] }
use windows::Win32::Storage::FileSystem::{
    GetLogicalDriveStringsW,
};


let drives: Vec<String> = unsafe {
    let buf_size = GetLogicalDriveStringsW(None) as usize;
    let mut buf = vec![0u16; buf_size];
    let ret = GetLogicalDriveStringsW(Some(buf.as_mut_slice())); // TODO: error handling if ret is 0
    String::from_utf16_lossy(&buf)
	.trim_matches('\0')  // remove both trailing nuls
	.split('\0')
	.map(String::from)
	.collect()
};

I didn't yet have time to think about how exactly to slot this into the app logic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants