Open tehbilly opened 9 months ago
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.
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.
This is to address mgunyho/tere#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:
..
at the drive root