From 32c9cbaae2b0a3d93680daa7cd467b8f0570cf2f Mon Sep 17 00:00:00 2001 From: Martchus Date: Thu, 17 Mar 2022 22:41:51 +0100 Subject: [PATCH] Use `makeNativePath()` instead of `u8path()` On non-Windows platforms the internal representation used for paths is the configured native (narrow) character set. Most of the time that's UTF-8 but only on Windows UTF-8 is *always* used for the internal representation. --- cli/mainfeatures.cpp | 12 ++++++++---- gui/tageditorwidget.cpp | 2 +- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/cli/mainfeatures.cpp b/cli/mainfeatures.cpp index 16a4ec0..5423444 100644 --- a/cli/mainfeatures.cpp +++ b/cli/mainfeatures.cpp @@ -35,6 +35,7 @@ #include #include #include +#include #include #include @@ -696,7 +697,8 @@ void setTagInfo(const SetTagInfoArgs &args) convertedValues.emplace_back(relevantDenotedValue->value, TagTextEncoding::Utf8, usedEncoding); } catch (const ConversionException &e) { diag.emplace_back(DiagLevel::Critical, - argsToString("Unable to parse value specified for field \"", denotedScope.field.name(), "\": ", e.what()), context); + argsToString("Unable to parse value specified for field \"", denotedScope.field.name(), "\": ", e.what()), + context); } continue; } @@ -746,9 +748,11 @@ void setTagInfo(const SetTagInfoArgs &args) convertedValues.emplace_back(std::move(value)); } } catch (const TagParser::Failure &) { - diag.emplace_back(DiagLevel::Critical, argsToString("Unable to parse specified file \"", path, "\": unable to determine MIME type"), context); + diag.emplace_back(DiagLevel::Critical, + argsToString("Unable to parse specified file \"", path, "\": unable to determine MIME type"), context); } catch (const ConversionException &e) { - diag.emplace_back(DiagLevel::Critical, argsToString("Unable to parse specified file \"", path, "\": ", e.what()), context); + diag.emplace_back( + DiagLevel::Critical, argsToString("Unable to parse specified file \"", path, "\": ", e.what()), context); } catch (const std::ios_base::failure &e) { diag.emplace_back(DiagLevel::Critical, argsToString("An IO error occurred when parsing the specified file \"", path, "\": ", e.what()), context); @@ -881,7 +885,7 @@ void setTagInfo(const SetTagInfoArgs &args) auto modifiedFilePath = std::filesystem::path(); fileInfo.setSaveFilePath(currentOutputFile != noMoreOutputFiles ? string(*currentOutputFile) : string()); if (args.preserveModificationTimeArg.isPresent()) { - modifiedFilePath = std::filesystem::u8path(fileInfo.saveFilePath().empty() ? fileInfo.path() : fileInfo.saveFilePath()); + modifiedFilePath = makeNativePath(fileInfo.saveFilePath().empty() ? fileInfo.path() : fileInfo.saveFilePath()); modificationDate = std::filesystem::last_write_time(modifiedFilePath, modificationDateError); } try { diff --git a/gui/tageditorwidget.cpp b/gui/tageditorwidget.cpp index e75d24f..e1dd942 100644 --- a/gui/tageditorwidget.cpp +++ b/gui/tageditorwidget.cpp @@ -1187,7 +1187,7 @@ bool TagEditorWidget::startSaving() auto modificationDate = std::filesystem::file_time_type(); auto modifiedFilePath = std::filesystem::path(); if (preserveModificationTime) { - modifiedFilePath = std::filesystem::u8path(m_fileInfo.saveFilePath().empty() ? m_fileInfo.path() : m_fileInfo.saveFilePath()); + modifiedFilePath = makeNativePath(m_fileInfo.saveFilePath().empty() ? m_fileInfo.path() : m_fileInfo.saveFilePath()); modificationDate = std::filesystem::last_write_time(modifiedFilePath, modificationDateError); } try {