mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-15 23:20:36 +01:00
Core/Updater: Use a different method for file reading
* Current method causes issues under CentOS 6 and could possibly
lead to cutted buffer content when reading in textmode.
* Closes #16209
(cherry picked from commit ae1a5c6c2b)
This commit is contained in:
@@ -142,14 +142,12 @@ UpdateFetcher::SQLUpdate UpdateFetcher::ReadSQLUpdate(boost::filesystem::path co
|
||||
std::ifstream in(file.c_str());
|
||||
WPFatal(in.is_open(), "Could not read an update file.");
|
||||
|
||||
auto const start_pos = in.tellg();
|
||||
in.ignore(std::numeric_limits<std::streamsize>::max());
|
||||
auto const char_count = in.gcount();
|
||||
in.seekg(start_pos);
|
||||
auto update = [&in] {
|
||||
std::ostringstream ss;
|
||||
ss << in.rdbuf();
|
||||
return Trinity::make_unique<std::string>(ss.str());
|
||||
}();
|
||||
|
||||
SQLUpdate const update(new std::string(char_count, char{}));
|
||||
|
||||
in.read(&(*update)[0], update->size());
|
||||
in.close();
|
||||
return update;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user