1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-08-26 18:21:04 +00:00

Introduce proper error handling for file streams

This commit is contained in:
sfan5 2024-05-08 20:37:10 +02:00
parent c38e0d05bf
commit 39fd9b93c3
23 changed files with 235 additions and 149 deletions

View file

@ -485,12 +485,9 @@ bool Schematic::serializeToLua(std::ostream *os, bool use_comments,
bool Schematic::loadSchematicFromFile(const std::string &filename,
const NodeDefManager *ndef, StringMap *replace_names)
{
std::ifstream is(filename.c_str(), std::ios_base::binary);
if (!is.good()) {
errorstream << __FUNCTION__ << ": unable to open file '"
<< filename << "'" << std::endl;
auto is = open_ifstream(filename.c_str(), true);
if (!is.good())
return false;
}
if (!m_ndef)
m_ndef = ndef;