Skip to content

Commit

Permalink
Check if given path is regular file
Browse files Browse the repository at this point in the history
  • Loading branch information
Aemony committed Feb 13, 2024
1 parent 1bd7687 commit f8bd98e
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/tabs/library.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1040,8 +1040,10 @@ SaveGameCover (app_record_s* pApp, std::wstring_view path)
if (path.empty())
return false;

std::error_code ec;
const std::filesystem::path fsPath (path.data());
std::wstring targetPath = L"";
std::wstring extOriginal = std::filesystem::path (path.data()).extension().wstring();
std::wstring extOriginal = fsPath.extension().wstring();
bool isURL = PathIsURL (path.data());

extOriginal = SKIF_Util_ToLowerW (extOriginal);
Expand Down Expand Up @@ -1075,8 +1077,8 @@ SaveGameCover (app_record_s* pApp, std::wstring_view path)
return false;
}

// For local files, check if they do. in fact, exist
if (! isURL && ! PathFileExists (path.data()))
// For local files, check if they do. in fact, exist and are local files
if (! isURL && ! std::filesystem::is_regular_file (fsPath, ec))
{
confirmPopupTitle = "Unsupported image format";
confirmPopupText = "Please use a supported image format:\n"
Expand Down Expand Up @@ -8431,6 +8433,7 @@ SKIF_UI_Tab_DrawLibrary (void)

if (! dragDroppedFilePath.empty())
{
PLOG_VERBOSE << "New drop was given: " << dragDroppedFilePath;
// A child thread will set refreshCover once done
if (SaveGameCover (pApp, dragDroppedFilePath))
{
Expand All @@ -8448,7 +8451,6 @@ SKIF_UI_Tab_DrawLibrary (void)
fAlpha = (_registry.bFadeCovers) ? 0.0f : 1.0f;
}


dragDroppedFilePath.clear();
}

Expand Down

0 comments on commit f8bd98e

Please sign in to comment.