aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Fedchin <anightik@gmail.com>2018-04-03 17:10:41 +0300
committerAnton Fedchin <anightik@gmail.com>2018-04-04 11:32:48 +0300
commitd780542170cf094d3a4abec6547da547fd21af14 (patch)
tree8d95af0a7ac8cd7fe89bbaecc4c1ce9dc4e10aa9
parentcde9602e736292ad651304cf6816794d64734fa1 (diff)
[win10] storage: cover enumerating removable storage into try-catch.
-rw-r--r--xbmc/storage/win10/Win10StorageProvider.cpp26
1 files 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);
}
}