diff options
| author | Naios <naios-dev@live.de> | 2016-02-20 20:18:42 +0100 |
|---|---|---|
| committer | Naios <naios-dev@live.de> | 2016-02-20 20:32:34 +0100 |
| commit | 716c952cb9f7bc0f75308bb4a716cdfe7de17281 (patch) | |
| tree | a894eaee0b9d45b81be2961b4be1b2f02f69afe6 /src | |
| parent | 2a186f29f4e5fd31b7ac2aa9eb2701d190259eb5 (diff) | |
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 ae1a5c6c2b82918850cb7b851e2f7dff33a40c57)
Diffstat (limited to 'src')
| -rw-r--r-- | src/server/database/Updater/UpdateFetcher.cpp | 12 | ||||
| -rw-r--r-- | src/server/database/Updater/UpdateFetcher.h | 2 |
2 files changed, 6 insertions, 8 deletions
diff --git a/src/server/database/Updater/UpdateFetcher.cpp b/src/server/database/Updater/UpdateFetcher.cpp index fd0dbdd4b5a..001fdf20610 100644 --- a/src/server/database/Updater/UpdateFetcher.cpp +++ b/src/server/database/Updater/UpdateFetcher.cpp @@ -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; } diff --git a/src/server/database/Updater/UpdateFetcher.h b/src/server/database/Updater/UpdateFetcher.h index 22a0d08c7f8..32f8516413d 100644 --- a/src/server/database/Updater/UpdateFetcher.h +++ b/src/server/database/Updater/UpdateFetcher.h @@ -103,7 +103,7 @@ private: typedef std::unordered_map<std::string, std::string> HashToFileNameStorage; typedef std::unordered_map<std::string, AppliedFileEntry> AppliedFileStorage; typedef std::vector<UpdateFetcher::DirectoryEntry> DirectoryStorage; - typedef std::shared_ptr<std::string> SQLUpdate; + typedef std::unique_ptr<std::string> SQLUpdate; LocaleFileStorage GetFileList() const; void FillFileListRecursively(Path const& path, LocaleFileStorage& storage, State const state, uint32 const depth) const; |
