avoid running 'GetVolumeInfotmationW' on network drives efficiently

avoid running 'GetVolumeInformationW' on network drives

use a variable to not re-do utf16 conversion, change [] to <> to be more visually distinct from inevitably wrapping ()

(cherry picked from commit 9338b10dd3e6614f1172cb38d086b0bc4be40dc8)
This commit is contained in:
Duke Manchester authored and Thaddeus Crews committed 2026-07-30 11:26:22 -05:00
1 parent 2d2d93443f
commit 25264af544
1 file changed
+7 -1
+7 -1
View File
@@ -143,8 +143,14 @@ void DirAccessWindows::_update_drives() {
String drive = String::chr('A' + i) + ':';
String path = drive + '\\';
String label;
Char16String cs = path.utf16();
UINT type = GetDriveTypeW((LPCWSTR)cs.get_data());
if (type == DRIVE_REMOTE) {
drives.push_back(DriveInfo{ drive, "<network>" });
continue;
}
char16_t wlabel[4096];
if (GetVolumeInformationW((LPCWSTR)(path).utf16().get_data(), (LPWSTR)wlabel, 4096, nullptr, nullptr, nullptr, nullptr, 0)) {
if (GetVolumeInformationW((LPCWSTR)cs.get_data(), (LPWSTR)wlabel, 4096, nullptr, nullptr, nullptr, nullptr, 0)) {
label = String::utf16(wlabel);
}
drives.push_back(DriveInfo{ drive, label });