Skip to content

Commit

Permalink
Core/Misc: Don't use tellg() to estimate file sizes
Browse files Browse the repository at this point in the history
  • Loading branch information
Shauren committed Oct 17, 2024
1 parent a6d84ec commit 0dd6dd7
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/server/game/DataStores/M2Stores.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "Log.h"
#include "M2Structure.h"
#include "Timer.h"
#include <boost/filesystem/operations.hpp>
#include <boost/filesystem/path.hpp>
#include <G3D/Vector4.h>
#include <fstream>
Expand Down Expand Up @@ -191,8 +192,7 @@ TC_GAME_API void LoadM2Cameras(std::string const& dataPath)
continue;

// Get file size
m2file.seekg(0, std::ios::end);
std::streamoff fileSize = m2file.tellg();
std::streamoff fileSize = boost::filesystem::file_size(filename);

// Reject if not at least the size of the header
if (static_cast<uint32>(fileSize) < sizeof(M2Header) + 4)
Expand All @@ -203,7 +203,6 @@ TC_GAME_API void LoadM2Cameras(std::string const& dataPath)
}

// Read 4 bytes (signature)
m2file.seekg(0, std::ios::beg);
char fileCheck[5];
m2file.read(fileCheck, 4);
fileCheck[4] = '\0';
Expand Down

0 comments on commit 0dd6dd7

Please sign in to comment.