Use _wopen under Windows to support unicode filenames
This commit is contained in:
parent
77da65ddf7
commit
e75ea5526a
|
@ -205,7 +205,7 @@ include(BasicConfig)
|
|||
|
||||
# find qtutilities
|
||||
if(WIDGETS_GUI OR QUICK_GUI)
|
||||
find_package(qtutilities 5.0.0 REQUIRED)
|
||||
find_package(qtutilities 5.3.0 REQUIRED)
|
||||
use_qt_utilities()
|
||||
endif()
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
#include <c++utilities/conversion/conversionexception.h>
|
||||
#include <c++utilities/io/ansiescapecodes.h>
|
||||
#include <c++utilities/io/catchiofailure.h>
|
||||
#include <c++utilities/io/nativefilestream.h>
|
||||
#include <c++utilities/misc/memory.h>
|
||||
|
||||
#if defined(GUI_QTWIDGETS) || defined(GUI_QTQUICK)
|
||||
|
@ -34,6 +35,7 @@ using namespace std;
|
|||
using namespace ApplicationUtilities;
|
||||
using namespace ConversionUtilities;
|
||||
using namespace ChronoUtilities;
|
||||
using namespace IoUtilities;
|
||||
using namespace EscapeCodes;
|
||||
using namespace Settings;
|
||||
using namespace Media;
|
||||
|
@ -958,6 +960,7 @@ void displayTagInfo(const Argument &fieldsArg, const Argument &filesArg, const A
|
|||
fileInfo.open(true);
|
||||
fileInfo.parseContainerFormat();
|
||||
fileInfo.parseTags();
|
||||
cout << file << endl;
|
||||
cout << "Tag information for \"" << file << "\":" << endl;
|
||||
const auto tags = fileInfo.tags();
|
||||
if(!tags.empty()) {
|
||||
|
@ -1379,7 +1382,7 @@ void extractField(const Argument &fieldArg, const Argument &attachmentArg, const
|
|||
outputFileExtension = BasicFileInfo::extension(outputFileArg.values().front());
|
||||
}
|
||||
for(const auto &value : values) {
|
||||
fstream outputFileStream;
|
||||
NativeFileStream outputFileStream;
|
||||
outputFileStream.exceptions(ios_base::failbit | ios_base::badbit);
|
||||
auto path = values.size() > 1 ? joinStrings({outputFilePathWithoutExtension, "-", value.second, outputFileExtension}) : outputFileArg.values().front();
|
||||
try {
|
||||
|
@ -1427,7 +1430,7 @@ void extractField(const Argument &fieldArg, const Argument &attachmentArg, const
|
|||
outputFileExtension = BasicFileInfo::extension(outputFileArg.values().front());
|
||||
}
|
||||
for(const auto &attachment : attachments) {
|
||||
fstream outputFileStream;
|
||||
NativeFileStream outputFileStream;
|
||||
outputFileStream.exceptions(ios_base::failbit | ios_base::badbit);
|
||||
auto path = attachments.size() > 1 ? joinStrings({outputFilePathWithoutExtension, "-", attachment.second, outputFileExtension}) : outputFileArg.values().front();
|
||||
try {
|
||||
|
|
|
@ -132,7 +132,7 @@ inline void HttpResultsModel::addReply(QNetworkReply *reply, Object object, Func
|
|||
{
|
||||
(m_replies << reply), connect(reply, &QNetworkReply::finished, object, handler);
|
||||
#ifdef DEBUG_BUILD
|
||||
std::cerr << "HTTP query: " << reply->url().toString().toLocal8Bit().data() << std::endl;
|
||||
std::cerr << "HTTP query: " << reply->url().toString().toUtf8().data() << std::endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -145,7 +145,7 @@ inline void HttpResultsModel::addReply(QNetworkReply *reply, Function handler)
|
|||
{
|
||||
(m_replies << reply), connect(reply, &QNetworkReply::finished, handler);
|
||||
#ifdef DEBUG_BUILD
|
||||
std::cerr << "HTTP query: " << reply->url().toString().toLocal8Bit().data() << std::endl;
|
||||
std::cerr << "HTTP query: " << reply->url().toString().toUtf8().data() << std::endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -7,8 +7,11 @@
|
|||
#include <tagparser/mediafileinfo.h>
|
||||
#include <tagparser/abstractattachment.h>
|
||||
|
||||
#include <qtutilities/misc/conversion.h>
|
||||
|
||||
#include <c++utilities/io/copy.h>
|
||||
#include <c++utilities/io/catchiofailure.h>
|
||||
#include <c++utilities/io/nativefilestream.h>
|
||||
|
||||
#include <QFileDialog>
|
||||
#include <QMessageBox>
|
||||
|
@ -17,6 +20,7 @@
|
|||
|
||||
using namespace std;
|
||||
using namespace IoUtilities;
|
||||
using namespace ConversionUtilities;
|
||||
using namespace Media;
|
||||
|
||||
namespace QtGui {
|
||||
|
@ -91,7 +95,7 @@ void AttachmentsEdit::addFile(const QString &path)
|
|||
// create and add attachment
|
||||
auto *attachment = fileInfo()->container()->createAttachment();
|
||||
attachment->setIgnored(true);
|
||||
attachment->setFile(path.toLocal8Bit().data());
|
||||
attachment->setFile(toNativeFileName(path).data());
|
||||
m_addedAttachments << attachment;
|
||||
m_model->addAttachment(-1, attachment, true, path);
|
||||
} else {
|
||||
|
@ -124,11 +128,11 @@ void AttachmentsEdit::extractSelected()
|
|||
if(!fileName.isEmpty()) {
|
||||
auto *data = attachment->data();
|
||||
auto &input = attachment->data()->stream();
|
||||
fstream file;
|
||||
NativeFileStream file;
|
||||
file.exceptions(ios_base::badbit | ios_base::failbit);
|
||||
try {
|
||||
input.seekg(data->startOffset());
|
||||
file.open(fileName.toLocal8Bit().data(), ios_base::out | ios_base::binary);
|
||||
file.open(toNativeFileName(fileName).data(), ios_base::out | ios_base::binary);
|
||||
CopyHelper<0x1000> helper;
|
||||
helper.copy(input, file, data->size());
|
||||
} catch(...) {
|
||||
|
|
|
@ -97,7 +97,7 @@ Media::TagTarget EnterTargetDialog::target() const
|
|||
{
|
||||
TagTarget target;
|
||||
target.setLevel(static_cast<uint64>(m_ui->levelSpinBox->value()));
|
||||
target.setLevelName(m_ui->levelNameLineEdit->text().toLocal8Bit().data());
|
||||
target.setLevelName(m_ui->levelNameLineEdit->text().toUtf8().data());
|
||||
addIds(target.tracks(), m_tracksModel);
|
||||
addIds(target.chapters(), m_chaptersModel);
|
||||
addIds(target.editions(), m_editionsModel);
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
#include <qtutilities/misc/dialogutils.h>
|
||||
#include <qtutilities/misc/desktoputils.h>
|
||||
#include <qtutilities/misc/trylocker.h>
|
||||
#include <qtutilities/misc/conversion.h>
|
||||
|
||||
#include <c++utilities/conversion/stringconversion.h>
|
||||
#include <c++utilities/io/path.h>
|
||||
|
@ -34,6 +35,7 @@ using namespace Media;
|
|||
using namespace Dialogs;
|
||||
using namespace Widgets;
|
||||
using namespace ThreadingUtils;
|
||||
using namespace ConversionUtilities;
|
||||
|
||||
namespace QtGui {
|
||||
|
||||
|
@ -502,7 +504,7 @@ void MainWindow::showSaveAsDlg()
|
|||
const QString path = QFileDialog::getSaveFileName(this, tr("Save changes as - ") + QCoreApplication::applicationName(),
|
||||
m_ui->tagEditorWidget->currentDir());
|
||||
if(!path.isEmpty()) {
|
||||
m_ui->tagEditorWidget->fileInfo().setSaveFilePath(path.toLocal8Bit().data());
|
||||
m_ui->tagEditorWidget->fileInfo().setSaveFilePath(toNativeFileName(path).data());
|
||||
m_ui->tagEditorWidget->applyEntriesAndSaveChangings();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,6 +12,8 @@
|
|||
#include <tagparser/vorbis/vorbiscomment.h>
|
||||
#include <tagparser/vorbis/vorbiscommentfield.h>
|
||||
|
||||
#include <qtutilities/misc/conversion.h>
|
||||
|
||||
#include <c++utilities/misc/memory.h>
|
||||
#include <c++utilities/io/catchiofailure.h>
|
||||
|
||||
|
@ -37,6 +39,7 @@
|
|||
|
||||
using namespace std;
|
||||
using namespace Media;
|
||||
using namespace ConversionUtilities;
|
||||
|
||||
namespace QtGui {
|
||||
|
||||
|
@ -314,7 +317,7 @@ void PicturePreviewSelection::addOfSelectedType(const QString &path)
|
|||
assert(m_currentTypeIndex < static_cast<unsigned int>(m_values.size()));
|
||||
TagValue &selectedCover = m_values[m_currentTypeIndex];
|
||||
try {
|
||||
MediaFileInfo fileInfo(path.toLocal8Bit().constData());
|
||||
MediaFileInfo fileInfo(toNativeFileName(path).constData());
|
||||
fileInfo.open(true);
|
||||
fileInfo.parseContainerFormat();
|
||||
auto mimeType = QString::fromLocal8Bit(fileInfo.mimeType());
|
||||
|
@ -327,7 +330,7 @@ void PicturePreviewSelection::addOfSelectedType(const QString &path)
|
|||
fileInfo.stream().seekg(0);
|
||||
fileInfo.stream().read(buff.get(), fileInfo.size());
|
||||
selectedCover.assignData(std::move(buff), fileInfo.size(), TagDataType::Picture);
|
||||
selectedCover.setMimeType(mimeType.toLocal8Bit().constData());
|
||||
selectedCover.setMimeType(mimeType.toUtf8().constData());
|
||||
emit pictureChanged();
|
||||
}
|
||||
}
|
||||
|
@ -438,7 +441,7 @@ void PicturePreviewSelection::changeMimeTypeOfSelected()
|
|||
bool ok;
|
||||
mimeType = QInputDialog::getText(this, tr("Enter/confirm mime type"), tr("Confirm or enter the mime type of the selected file."), QLineEdit::Normal, mimeType, &ok);
|
||||
if(ok) {
|
||||
selectedCover.setMimeType(mimeType.toLocal8Bit().data());
|
||||
selectedCover.setMimeType(mimeType.toUtf8().data());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
#include <tagparser/ogg/oggcontainer.h>
|
||||
|
||||
#include <qtutilities/misc/dialogutils.h>
|
||||
#include <qtutilities/misc/conversion.h>
|
||||
#include <qtutilities/widgets/clearlineedit.h>
|
||||
|
||||
#include <c++utilities/conversion/stringconversion.h>
|
||||
|
@ -57,6 +58,7 @@ using namespace Dialogs;
|
|||
using namespace Widgets;
|
||||
using namespace Media;
|
||||
using namespace Models;
|
||||
using namespace ConversionUtilities;
|
||||
|
||||
namespace QtGui {
|
||||
|
||||
|
@ -738,7 +740,7 @@ bool TagEditorWidget::startParsing(const QString &path, bool forceRefresh)
|
|||
// set path of file info
|
||||
m_currentPath = path;
|
||||
m_fileInfo.setSaveFilePath(string());
|
||||
m_fileInfo.setPath(path.toLocal8Bit().data());
|
||||
m_fileInfo.setPath(toNativeFileName(path).data());
|
||||
// update file name and directory
|
||||
QFileInfo fileInfo(path);
|
||||
m_lastDir = m_currentDir;
|
||||
|
|
|
@ -10,6 +10,8 @@
|
|||
#include <tagparser/tagvalue.h>
|
||||
#include <tagparser/exceptions.h>
|
||||
|
||||
#include <qtutilities/misc/conversion.h>
|
||||
|
||||
#include <c++utilities/conversion/conversionexception.h>
|
||||
#include <c++utilities/io/catchiofailure.h>
|
||||
|
||||
|
@ -135,7 +137,7 @@ const QString &TagEditorObject::newRelativeDirectory() const
|
|||
|
||||
TAGEDITOR_JS_VALUE TagEditorObject::parseFileInfo(const QString &fileName)
|
||||
{
|
||||
MediaFileInfo fileInfo(fileName.toLocal8Bit().data());
|
||||
MediaFileInfo fileInfo(toNativeFileName(fileName).data());
|
||||
|
||||
auto fileInfoObject = m_engine->newObject();
|
||||
fileInfoObject.setProperty(QStringLiteral("currentName"), QString::fromLocal8Bit(fileInfo.fileName(false).data()));
|
||||
|
|
Loading…
Reference in New Issue