Fix audio-file list for utf8

Signed-off-by: falkTX <falktx@falktx.com>
This commit is contained in:
falkTX 2022-02-08 05:11:54 +00:00
parent 9a9dd654af
commit 34100d7347
No known key found for this signature in database
GPG key ID: CDBAA37ABC74FBA0

View file

@ -437,9 +437,15 @@ struct AudioFileListWidget : ImGuiWidget {
}; };
using namespace ghc::filesystem; using namespace ghc::filesystem;
currentDirectory = path(module->currentFile).parent_path().string(); const path currentFile = u8path(module->currentFile);
currentDirectory = currentFile.parent_path().generic_u8string();
directory_iterator it;
try {
it = directory_iterator(u8path(currentDirectory));
} DISTRHO_SAFE_EXCEPTION_RETURN("Failed to open current directory",);
directory_iterator it(currentDirectory);
for (directory_iterator itb = begin(it), ite=end(it); itb != ite; ++itb) for (directory_iterator itb = begin(it), ite=end(it); itb != ite; ++itb)
{ {
if (! itb->is_regular_file()) if (! itb->is_regular_file())
@ -450,7 +456,7 @@ struct AudioFileListWidget : ImGuiWidget {
{ {
if (extension.compare(supportedExtensions[i]) == 0) if (extension.compare(supportedExtensions[i]) == 0)
{ {
currentFiles.push_back({ filepath.string(), filepath.filename().string() }); currentFiles.push_back({ filepath.generic_u8string(), filepath.filename().generic_u8string() });
break; break;
} }
} }
@ -460,7 +466,7 @@ struct AudioFileListWidget : ImGuiWidget {
for (size_t index = 0; index < currentFiles.size(); ++index) for (size_t index = 0; index < currentFiles.size(); ++index)
{ {
if (currentFiles[index].full.compare(module->currentFile) == 0) if (currentFiles[index].full.compare(currentFile) == 0)
{ {
selectedFile = index; selectedFile = index;
break; break;