Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

win10: filesystem - catch possible exception #14122

Merged
merged 1 commit into from
Jun 28, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 19 additions & 10 deletions xbmc/platform/win10/filesystem/WinLibraryFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -269,19 +269,28 @@ bool CWinLibraryFile::IsInAccessList(const CURL& url)
static std::string localPath;
static std::string packagePath;

if (localPath.empty())
localPath = FromW(ApplicationData::Current().LocalFolder().Path().c_str());
try
{
if (localPath.empty())
localPath = FromW(ApplicationData::Current().LocalFolder().Path().c_str());

if (packagePath.empty())
packagePath = FromW(Package::Current().InstalledLocation().Path().c_str());
if (packagePath.empty())
packagePath = FromW(Package::Current().InstalledLocation().Path().c_str());

// don't check files inside local folder and installation folder
if ( StringUtils::StartsWithNoCase(url.Get(), localPath)
|| StringUtils::StartsWithNoCase(url.Get(), packagePath))
return false;
// 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())
|| IsInList(url, StorageApplicationPermissions::MostRecentlyUsedList());
return IsInList(url, StorageApplicationPermissions::FutureAccessList())
|| IsInList(url, StorageApplicationPermissions::MostRecentlyUsedList());
}
catch (const winrt::hresult_error& ex)
{
std::string strError = FromW(ex.message().c_str());
CLog::LogF(LOGERROR, "unexpected error occurs during WinRT API call: {}", strError);
}
return false;
}

bool CWinLibraryFile::OpenIntenal(const CURL &url, FileAccessMode mode)
Expand Down