mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-30 22:15:32 +00:00
ConstrainedDataStream: print the name of the file in exceptions
This commit is contained in:
parent
51e451e249
commit
2abc033655
1 changed files with 52 additions and 42 deletions
|
@ -15,6 +15,7 @@ public:
|
||||||
static const size_t sBufferThreshold = 1024; // reads larger than this bypass buffering as cost of memcpy outweighs cost of system call
|
static const size_t sBufferThreshold = 1024; // reads larger than this bypass buffering as cost of memcpy outweighs cost of system call
|
||||||
|
|
||||||
ConstrainedDataStream(const Ogre::String &fname, size_t start, size_t length)
|
ConstrainedDataStream(const Ogre::String &fname, size_t start, size_t length)
|
||||||
|
: Ogre::DataStream(fname)
|
||||||
{
|
{
|
||||||
mFile.open (fname.c_str ());
|
mFile.open (fname.c_str ());
|
||||||
mSize = length != 0xFFFFFFFF ? length : mFile.size () - start;
|
mSize = length != 0xFFFFFFFF ? length : mFile.size () - start;
|
||||||
|
@ -29,6 +30,8 @@ public:
|
||||||
|
|
||||||
|
|
||||||
size_t read(void* buf, size_t count)
|
size_t read(void* buf, size_t count)
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
assert (mPos <= mSize);
|
assert (mPos <= mSize);
|
||||||
|
|
||||||
|
@ -88,6 +91,13 @@ public:
|
||||||
mPos += count;
|
mPos += count;
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
catch (std::exception& e)
|
||||||
|
{
|
||||||
|
std::stringstream error;
|
||||||
|
error << "Failed to read '" << mName << "': " << e.what();
|
||||||
|
throw std::runtime_error(error.str());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void skip(long count)
|
void skip(long count)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue