git repos / blockattack-game

commit b830df03

sago007 · 2016-06-11 16:17
b830df0385b65f2ace774b1cefe75a04ae0e8d6f patch · browse files
parent bbb1d8798c550087569a570552630e41617834dd

Now we support reading binary files. Not that we use that at the moment

Changed files

M source/code/sago/SagoMisc.cpp before
diff --git a/source/code/sago/SagoMisc.cpp b/source/code/sago/SagoMisc.cpp index f4a1235..e0f2c0b 100644 --- a/source/code/sago/SagoMisc.cpp +++ b/source/code/sago/SagoMisc.cpp
@@ -58,7 +58,7 @@ std::string GetFileContent(const char* filename) {
}
PHYSFS_file* myfile = PHYSFS_openRead(filename);
unsigned int m_size = PHYSFS_fileLength(myfile);
- std::unique_ptr<char[]> m_data(new char[m_size+1]);
+ std::unique_ptr<char[]> m_data(new char[m_size]);
int length_read = PHYSFS_read (myfile, m_data.get(), 1, m_size);
if (length_read != (int)m_size) {
PHYSFS_close(myfile);
@@ -66,8 +66,8 @@ std::string GetFileContent(const char* filename) {
return ret;
}
PHYSFS_close(myfile);
- m_data[m_size] = 0; //ensure that we are 0 terminated
- ret = m_data.get();
+ //Now create a std::string
+ ret = string(m_data.get(), m_data.get()+m_size);
return ret;
}