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

Loading…
Cancel
Save