On macos, you can't use a wstring inside an fstream
master^2
gorbit99 6 years ago committed by GitHub
parent 5d24255fde
commit 17ce23a1c5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 62
      olcConsoleGameEngineSDL.h

@ -368,44 +368,48 @@ public:
return m_Colours[sy * nWidth + sx];
}
bool Save(std::string sFile)
{
std::ofstream f(sFile.c_str(), std::ios::out | std::ios::binary);
if (!f.is_open()) return false;
bool Save(std::wstring sFile)
{
std::string path(sFile.begin(), sFile.end());
f.write((char*)&nWidth, sizeof(int));
f.write((char*)&nHeight, sizeof(int));
f.write((char*)m_Colours, sizeof(short) * nWidth * nHeight);
f.write((char*)m_Glyphs, sizeof(wchar_t) * nWidth * nHeight);
std::ofstream f(path.c_str(), std::ios::out | std::ios::binary);
if (!f.is_open()) return false;
f.close();
f.write((char*)&nWidth, sizeof(int));
f.write((char*)&nHeight, sizeof(int));
f.write((char*)m_Colours, sizeof(short) * nWidth * nHeight);
f.write((char*)m_Glyphs, sizeof(wchar_t) * nWidth * nHeight);
return true;
}
f.close();
bool Load(std::string sFile)
{
delete[] m_Glyphs;
delete[] m_Colours;
nWidth = 0;
nHeight = 0;
return true;
}
bool Load(std::wstring sFile)
{
delete[] m_Glyphs;
delete[] m_Colours;
nWidth = 0;
nHeight = 0;
std::ifstream f(sFile.c_str(), std::ios::in | std::ios::binary);
if (!f.is_open()) return false;
std::string path(sFile.begin(), sFile.end());
// get file data
f.read ((char*)&nWidth, sizeof(int));
f.read ((char*)&nHeight, sizeof(int));
std::ifstream f(path.c_str(), std::ios::in | std::ios::binary);
if (!f.is_open()) return false;
Create(nWidth, nHeight);
f.read ((char*)m_Colours, sizeof(short) * nWidth * nHeight);
f.read ((char*)m_Glyphs, sizeof(wchar_t) * nWidth * nHeight);
// get file data
f.read((char*)&nWidth, sizeof(int));
f.read((char*)&nHeight, sizeof(int));
f.close();
Create(nWidth, nHeight);
return true;
}
f.read((char*)m_Colours, sizeof(short) * nWidth * nHeight);
f.read((char*)m_Glyphs, sizeof(wchar_t) * nWidth * nHeight);
f.close();
return true;
}
};
int len = 0, done = 0, bits = 0, which = 0,

Loading…
Cancel
Save