disk_name/
lib.rs

1use std::path::Path;
2
3/// Fetches all existing hard drive letters
4///
5/// Returns a [`Vec<String>`]
6pub fn get_letters() -> Vec<String> {
7    HARD_DRIVE_NAMES
8        .iter()
9        .filter(|name| Path::new(name).exists())
10        .map(|name| name.to_string())
11        .collect()
12}
13
14/// Static array of all possible drive letters from A-Z
15static HARD_DRIVE_NAMES: [&str; 26] = [
16    "A:\\", "B:\\", "C:\\", "D:\\", "E:\\",
17    "F:\\", "G:\\", "H:\\", "I:\\", "J:\\",
18    "K:\\", "L:\\", "M:\\", "N:\\", "O:\\",
19    "P:\\", "Q:\\", "R:\\", "S:\\", "T:\\",
20    "U:\\", "V:\\", "W:\\", "X:\\", "Y:\\",
21    "Z:\\",
22];