Fix loading of new-format scenarios on Windows
This commit is contained in:
@@ -1873,8 +1873,9 @@ bool load_scenario_v2(fs::path file_to_load, cScenario& scenario) {
|
||||
fs::path path = tempDir/fname;
|
||||
fs::create_directories(path.parent_path());
|
||||
std::istream& graphic = pack.getFile(fname);
|
||||
std::ofstream fout(path.string().c_str());
|
||||
std::ofstream fout(path.string().c_str(), std::ios::binary);
|
||||
fout << graphic.rdbuf();
|
||||
fout.close();
|
||||
i++;
|
||||
}
|
||||
if(i > 0)
|
||||
@@ -1885,8 +1886,9 @@ bool load_scenario_v2(fs::path file_to_load, cScenario& scenario) {
|
||||
fs::path path = tempDir/fname;
|
||||
fs::create_directories(path.parent_path());
|
||||
std::istream& snd = pack.getFile(fname);
|
||||
std::ofstream fout(path.string().c_str());
|
||||
std::ofstream fout(path.string().c_str(), std::ios::binary);
|
||||
fout << snd.rdbuf();
|
||||
fout.close();
|
||||
i++;
|
||||
}
|
||||
if(i > 0)
|
||||
|
@@ -77,6 +77,7 @@ void tarball::readFrom(std::istream& in) {
|
||||
files.push_back(tarfile());
|
||||
header_posix_ustar& header = files.back().header;
|
||||
in.read((char*)&header, sizeof(header_posix_ustar));
|
||||
if(in.eof()) break; // Because it seems MSVC doesn't set the EOFbit until a read fails? Or something?
|
||||
files.back().filename = header.name;
|
||||
unsigned long long size;
|
||||
sscanf(header.size, "%llo", &size);
|
||||
@@ -103,10 +104,8 @@ std::ostream& tarball::newFile(std::string fname) {
|
||||
|
||||
std::istream& tarball::getFile(std::string fname) {
|
||||
for(tarfile& entry : files) {
|
||||
if(entry.filename == fname) {
|
||||
entry.contents.seekg(0);
|
||||
if(entry.filename == fname)
|
||||
return entry.contents;
|
||||
}
|
||||
}
|
||||
// If the file doesn't exist, return an empty stream
|
||||
static std::istringstream empty;
|
||||
|
Reference in New Issue
Block a user