From d780542170cf094d3a4abec6547da547fd21af14 Mon Sep 17 00:00:00 2001 From: Anton Fedchin Date: Tue, 3 Apr 2018 17:10:41 +0300 Subject: [win10] storage: cover enumerating removable storage into try-catch. --- xbmc/storage/win10/Win10StorageProvider.cpp | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/xbmc/storage/win10/Win10StorageProvider.cpp b/xbmc/storage/win10/Win10StorageProvider.cpp index ac22df724f..56371ba6a8 100644 --- a/xbmc/storage/win10/Win10StorageProvider.cpp +++ b/xbmc/storage/win10/Win10StorageProvider.cpp @@ -78,17 +78,23 @@ void CStorageProvider::GetLocalDrives(VECSOURCES &localDrives) void CStorageProvider::GetRemovableDrives(VECSOURCES &removableDrives) { using KODI::PLATFORM::WINDOWS::FromW; - - auto devicesView = Wait(Windows::Storage::KnownFolders::RemovableDevices->GetFoldersAsync()); - for (unsigned i = 0; i < devicesView->Size; i++) + try + { + auto devicesView = Wait(Windows::Storage::KnownFolders::RemovableDevices->GetFoldersAsync()); + for (unsigned i = 0; i < devicesView->Size; i++) + { + CMediaSource source; + auto device = devicesView->GetAt(i); + source.strName = FromW(device->DisplayName->Data()); + std::string driveLetter = FromW(device->Name->Data()).substr(0, 1); + source.strPath = "win-lib://removable/" + driveLetter + "/"; + source.m_iDriveType = CMediaSource::SOURCE_TYPE_REMOVABLE; + + removableDrives.push_back(source); + } + } + catch (Platform::Exception^) { - CMediaSource source; - auto device = devicesView->GetAt(i); - source.strName = FromW(device->DisplayName->Data()); - source.strPath = "win-lib://removable/" + FromW(device->Name->Data()).substr(0, 1) + "/"; - source.m_iDriveType = CMediaSource::SOURCE_TYPE_REMOVABLE; - - removableDrives.push_back(source); } } -- cgit v1.2.3