aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Fedchin <anightik@gmail.com>2018-06-13 17:40:50 +0300
committerAnton Fedchin <anightik@gmail.com>2018-06-18 09:11:24 +0300
commitc7224c354902c288bae066ad7b3b81eeb3c89c60 (patch)
tree57dc1c166f95c73cf76700febc59984235604d8d
parente3e5c9b547ae5e4f59fdb2f92140a8601baea914 (diff)
filesystem: CWinLibraryFile: optimizations and fix usage access lists.
-rw-r--r--xbmc/platform/win10/filesystem/WinLibraryFile.cpp31
1 files changed, 16 insertions, 15 deletions
diff --git a/xbmc/platform/win10/filesystem/WinLibraryFile.cpp b/xbmc/platform/win10/filesystem/WinLibraryFile.cpp
index 12872cb8bf..6bc55d467d 100644
--- a/xbmc/platform/win10/filesystem/WinLibraryFile.cpp
+++ b/xbmc/platform/win10/filesystem/WinLibraryFile.cpp
@@ -43,6 +43,7 @@ namespace winrt
{
using namespace Windows::Foundation;
}
+using namespace winrt::Windows::ApplicationModel;
using namespace winrt::Windows::Foundation::Collections;
using namespace winrt::Windows::Security::Cryptography;
using namespace winrt::Windows::Storage;
@@ -264,17 +265,19 @@ int CWinLibraryFile::Stat(struct __stat64* statData)
bool CWinLibraryFile::IsInAccessList(const CURL& url)
{
- // skip local folder and installation folder
using KODI::PLATFORM::WINDOWS::FromW;
+ static std::string localPath;
+ static std::string packagePath;
- auto localFolder = winrt::Windows::Storage::ApplicationData::Current().LocalFolder();
- std::string path = FromW(localFolder.Path().c_str());
- if (StringUtils::StartsWithNoCase(url.Get(), path))
- return false;
+ if (localPath.empty())
+ localPath = FromW(ApplicationData::Current().LocalFolder().Path().c_str());
+
+ if (packagePath.empty())
+ packagePath = FromW(Package::Current().InstalledLocation().Path().c_str());
- auto appFolder = winrt::Windows::ApplicationModel::Package::Current().InstalledLocation();
- path = FromW(appFolder.Path().c_str());
- if (StringUtils::StartsWithNoCase(url.Get(), path))
+ // don't check files inside local folder and installation folder
+ if ( StringUtils::StartsWithNoCase(url.Get(), localPath)
+ || StringUtils::StartsWithNoCase(url.Get(), packagePath))
return false;
return IsInList(url, StorageApplicationPermissions::FutureAccessList())
@@ -359,7 +362,7 @@ StorageFile CWinLibraryFile::GetFile(const CURL& url)
, error.c_str());
}
}
- else if (url.GetProtocol() == "file" || url.GetProtocol().empty())
+ else if (url.IsProtocol("file") || url.GetProtocol().empty())
{
// check that a file in feature access list or most rescently used list
// search in FAL
@@ -368,10 +371,10 @@ StorageFile CWinLibraryFile::GetFile(const CURL& url)
if (token.empty())
{
// serach in MRU list
- IStorageItemAccessList list = StorageApplicationPermissions::MostRecentlyUsedList();
+ list = StorageApplicationPermissions::MostRecentlyUsedList();
token = GetTokenFromList(url, list);
}
- if (token.empty())
+ if (!token.empty())
return Wait(list.GetFileAsync(token));
}
@@ -391,12 +394,10 @@ winrt::hstring CWinLibraryFile::GetTokenFromList(const CURL& url, const IStorage
return nullptr;
using KODI::PLATFORM::WINDOWS::ToW;
- std::string filePath = url.Get();
- std::wstring filePathW = ToW(filePath);
+ std::wstring filePathW = ToW(url.Get());
- for (uint32_t i = 0; i < listview.Size(); i++)
+ for(auto&& listEntry : listview)
{
- auto listEntry = listview.GetAt(i);
if (listEntry.Metadata == filePathW)
{
return listEntry.Token;