Browse Source

ObjImporter: open the file as binary.

Apparently opening the file as text would NOT properly handle \r\n and
will break everything posssible instead. What a day!
pull/107/head
Vladimír Vondruš 11 years ago
parent
commit
6547a59f0b
  1. 4
      src/MagnumPlugins/ObjImporter/ObjImporter.cpp

4
src/MagnumPlugins/ObjImporter/ObjImporter.cpp

@ -120,8 +120,7 @@ void ObjImporter::doClose() { _file.reset(); }
bool ObjImporter::doIsOpened() const { return !!_file; }
void ObjImporter::doOpenFile(const std::string& filename) {
/* Open file in *text* mode (to avoid \r handling) */
std::unique_ptr<std::istream> in{new std::ifstream{filename}};
std::unique_ptr<std::istream> in{new std::ifstream{filename, std::ios::binary}};
if(!in->good()) {
Error() << "Trade::ObjImporter::openFile(): cannot open file" << filename;
return;
@ -133,7 +132,6 @@ void ObjImporter::doOpenFile(const std::string& filename) {
}
void ObjImporter::doOpenData(Containers::ArrayView<const char> data) {
/* Open file in *text* mode (to avoid \r handling) */
_file.reset(new File);
_file->in.reset(new std::istringstream{{data.begin(), data.size()}});

Loading…
Cancel
Save