Skip to content

Commit

Permalink
Fix file name encoding issues with ZynAddSubFX on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
PhysSong committed Jul 5, 2018
1 parent 792e478 commit 9d0aae2
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions plugins/zynaddsubfx/zynaddsubfx/src/Misc/QtXmlWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,13 @@
#include <sstream>
#include <cstdarg>
#include <zlib.h>
#include "lmmsconfig.h"
#include "../globals.h"
#include "Util.h"

// Include LMMS headers
#include "lmmsconfig.h"
#include "IoHelper.h"


struct XmlData
{
Expand Down Expand Up @@ -193,11 +196,12 @@ int QtXmlWrapper::dosavefile(const char *filename,
int compression,
const char *xmldata) const
{
FILE *file = F_OPEN_UTF8(std::string(filename), "w");
if(file == NULL) {
return -1;
}

if(compression == 0) {
FILE *file;
file = fopen(filename, "w");
if(file == NULL)
return -1;
fputs(xmldata, file);
fclose(file);
}
Expand All @@ -210,7 +214,7 @@ int QtXmlWrapper::dosavefile(const char *filename,
snprintf(options, 10, "wb%d", compression);

gzFile gzfile;
gzfile = gzopen(filename, options);
gzfile = gzdopen(fileToDescriptor(file), options);
if(gzfile == NULL)
return -1;
gzputs(gzfile, xmldata);
Expand Down Expand Up @@ -313,7 +317,8 @@ int QtXmlWrapper::loadXMLfile(const std::string &filename)
char *QtXmlWrapper::doloadfile(const std::string &filename) const
{
char *xmldata = NULL;
gzFile gzfile = gzopen(filename.c_str(), "rb");

gzFile gzfile = gzdopen(fileToDescriptor(F_OPEN_UTF8(filename, "rb")), "rb");

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

0 comments on commit 9d0aae2

Please sign in to comment.