Skip to content

Commit

Permalink
fix for UTF-8
Browse files Browse the repository at this point in the history
  • Loading branch information
RevenantX committed Oct 19, 2020
1 parent 14992ba commit 24258b7
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions foo_cuefixer/foo_cuefixer.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#include <SDK/foobar2000.h>
#include <Shlwapi.h>

DECLARE_COMPONENT_VERSION("CUE fixer", "1.23", "CUE Fixer by RevenantX");
VALIDATE_COMPONENT_FILENAME("foo_cuefixer.dll");
Expand Down Expand Up @@ -40,13 +39,19 @@ class playlist_cuefixer : public playlist_callback_static

pfc::string fileDir(pfc::io::path::getParent(itemHandle->get_path()));
pfc::string referencedFullPath(pfc::io::path::combine(fileDir, refField));

if(!PathFileExistsA(referencedFullPath.subString(7).c_str()))
const char* path = referencedFullPath.subString(7).c_str();
int count = MultiByteToWideChar(CP_UTF8, 0, path, -1, nullptr, 0);
wchar_t* pathWide = new wchar_t[count];
MultiByteToWideChar(CP_UTF8, 0, path, -1, pathWide, count);

if(GetFileAttributesW(pathWide) == INVALID_FILE_ATTRIBUTES)
{
delete pathWide;
entriesToRemove->add_item(itemHandle);
removeCount++;
continue;
}
delete pathWide;

//check against added items
for (t_size j = 0; j < addedItemsCount; j++)
Expand Down

0 comments on commit 24258b7

Please sign in to comment.