Skip to content

Commit 9d0aae2

Browse files
committed
Fix file name encoding issues with ZynAddSubFX on Windows
1 parent 792e478 commit 9d0aae2

1 file changed

Lines changed: 12 additions & 7 deletions

File tree

plugins/zynaddsubfx/zynaddsubfx/src/Misc/QtXmlWrapper.cpp

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,13 @@
5555
#include <sstream>
5656
#include <cstdarg>
5757
#include <zlib.h>
58-
#include "lmmsconfig.h"
5958
#include "../globals.h"
6059
#include "Util.h"
6160

61+
// Include LMMS headers
62+
#include "lmmsconfig.h"
63+
#include "IoHelper.h"
64+
6265

6366
struct XmlData
6467
{
@@ -193,11 +196,12 @@ int QtXmlWrapper::dosavefile(const char *filename,
193196
int compression,
194197
const char *xmldata) const
195198
{
199+
FILE *file = F_OPEN_UTF8(std::string(filename), "w");
200+
if(file == NULL) {
201+
return -1;
202+
}
203+
196204
if(compression == 0) {
197-
FILE *file;
198-
file = fopen(filename, "w");
199-
if(file == NULL)
200-
return -1;
201205
fputs(xmldata, file);
202206
fclose(file);
203207
}
@@ -210,7 +214,7 @@ int QtXmlWrapper::dosavefile(const char *filename,
210214
snprintf(options, 10, "wb%d", compression);
211215

212216
gzFile gzfile;
213-
gzfile = gzopen(filename, options);
217+
gzfile = gzdopen(fileToDescriptor(file), options);
214218
if(gzfile == NULL)
215219
return -1;
216220
gzputs(gzfile, xmldata);
@@ -313,7 +317,8 @@ int QtXmlWrapper::loadXMLfile(const std::string &filename)
313317
char *QtXmlWrapper::doloadfile(const std::string &filename) const
314318
{
315319
char *xmldata = NULL;
316-
gzFile gzfile = gzopen(filename.c_str(), "rb");
320+
321+
gzFile gzfile = gzdopen(fileToDescriptor(F_OPEN_UTF8(filename, "rb")), "rb");
317322

318323
if(gzfile != NULL) { //The possibly compressed file opened
319324
std::stringstream strBuf; //reading stream

0 commit comments

Comments
 (0)