diff options
-rw-r--r-- | xbmc/platform/win10/filesystem/WinLibraryFile.cpp | 31 |
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; |