From 188f1a1b7e9b625d7d155ec96d5b7a0ebae2e3bb Mon Sep 17 00:00:00 2001 From: ts-korhonen Date: Sat, 15 Jan 2022 00:07:01 +0200 Subject: [PATCH] qt: fix plat_fopen() encoding --- src/qt/qt_platform.cpp | 66 +----------------------------------------- 1 file changed, 1 insertion(+), 65 deletions(-) diff --git a/src/qt/qt_platform.cpp b/src/qt/qt_platform.cpp index 6f3a05c98..f3de30485 100644 --- a/src/qt/qt_platform.cpp +++ b/src/qt/qt_platform.cpp @@ -131,71 +131,7 @@ plat_timer_read(void) FILE * plat_fopen(const char *path, const char *mode) { - /* - QString filepath(path); - if (filepath.isEmpty()) { - return nullptr; - } - - qWarning() << "plat_fopen" << filepath; - bool ok = false; - QFile file(filepath); - auto mode_len = strlen(mode); - for (size_t i = 0; i < mode_len; ++i) { - switch (mode[i]) { - case 'r': - ok = file.open(QIODevice::ReadOnly); - break; - case 'w': - ok = file.open(QIODevice::ReadWrite); - break; - case 'b': - case 't': - break; - default: - qWarning() << "Unhandled open mode" << mode[i]; - } - } - - if (ok) { - qDebug() << "filehandle" << file.handle(); - QFile returned; - qDebug() << "\t" << returned.open(file.handle(), file.openMode(), QFileDevice::FileHandleFlag::DontCloseHandle); - return fdopen(returned.handle(), mode); - } else { - return nullptr; - } - */ - -/* Not sure if any this is necessary, fopen seems to work on Windows -Manaatti -#ifdef Q_OS_WINDOWS - wchar_t *pathw, *modew; - int len; - FILE *fp; - - if (acp_utf8) - return fopen(path, mode); - else { - len = mbstoc16s(NULL, path, 0) + 1; - pathw = malloc(sizeof(wchar_t) * len); - mbstoc16s(pathw, path, len); - - len = mbstoc16s(NULL, mode, 0) + 1; - modew = malloc(sizeof(wchar_t) * len); - mbstoc16s(modew, mode, len); - - fp = _wfopen(pathw, modew); - - free(pathw); - free(modew); - - return fp; - } -#endif -#ifdef Q_OS_UNIX -*/ - return fopen(path, mode); -//#endif + return fopen(QString::fromUtf8(path).toLocal8Bit(), mode); } FILE *