From 2b2f5c3d234c908a84324bf03484a449fda27865 Mon Sep 17 00:00:00 2001 From: Jamie Reece Wilson Date: Fri, 12 Jul 2024 16:21:39 +0100 Subject: [PATCH] [*] Win32: added nvme pcie check under fs devices --- Source/IO/FS/FSPlatformDevices.NT.cpp | 5 +++++ Source/IO/FS/FSPlatformDevices.cpp | 29 +++++++++++---------------- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/Source/IO/FS/FSPlatformDevices.NT.cpp b/Source/IO/FS/FSPlatformDevices.NT.cpp index 09723200..8f1e0ba2 100644 --- a/Source/IO/FS/FSPlatformDevices.NT.cpp +++ b/Source/IO/FS/FSPlatformDevices.NT.cpp @@ -568,6 +568,11 @@ namespace Aurora::IO::FS } } + if (AuCodepointsToLower(device.devicePath).find("ven_nvme") != AuString::npos) + { + device.bus = EFSBusType::eBusNVMePCIe; + } + bSuccess = pSetupDiGetDeviceRegistryPropertyA(hIntDevInfo, &deviceInfoData, SPDRP_HARDWAREID, &dwDataType, (PBYTE)szBuffer, sizeof(szBuffer), &dwRequiredSize); diff --git a/Source/IO/FS/FSPlatformDevices.cpp b/Source/IO/FS/FSPlatformDevices.cpp index 8913c87b..2e6bc6fa 100644 --- a/Source/IO/FS/FSPlatformDevices.cpp +++ b/Source/IO/FS/FSPlatformDevices.cpp @@ -41,7 +41,8 @@ namespace Aurora::IO::FS AUKN_SYM AuResult GetFSDeviceByFilePath(const AuString &path) { - AuList> devs; + AuPair lastDev = + AuMakePair(0, nullptr); InitPlatformFSCacheAtLoad(); @@ -51,37 +52,31 @@ namespace Aurora::IO::FS return {}; } - { - AU_LOCK_GUARD(gFSDirMutex); + AU_LOCK_GUARD(gFSDirMutex); - for (const auto &refFSDevice : gCachedDevices) + for (const auto &refFSDevice : gCachedDevices) + { + for (const auto &refPart : refFSDevice.partitions) { - for (const auto &refPart : refFSDevice.partitions) // todo sort + for (const auto &refMnt : refPart.filesystemMountPoints) { - for (const auto &refMnt : refPart.filesystemMountPoints) // todo sort + if (AuStartsWith(path, refMnt)) { - if (AuStartsWith(path, refMnt)) + if (AuGet<0>(lastDev) < refMnt.size()) { - devs.push_back(AuMakePair(refMnt.size(), &refFSDevice)); + lastDev = AuMakePair(refMnt.size(), &refFSDevice); } } } } } - if (devs.empty()) + if (AuGet<0>(lastDev) == 0) { return {}; } - std::sort(devs.begin(), - devs.end(), - [](AuPair a, AuPair b) - { - return AuGet<0>(a) > AuGet<0>(b); - }); - - auto copy = AuGet<1>(devs[0]); + auto copy = *AuGet<1>(lastDev); return AuMove(copy); }