mirror of
https://github.com/Mauler125/r5sdk.git
synced 2025-02-09 19:15:03 +01:00
Compute the file size properly
This commit is contained in:
parent
30e360e3b7
commit
053f284029
@ -40,16 +40,14 @@ bool CIOStream::Open(const fs::path& fsFilePath, Mode_t eMode)
|
||||
{
|
||||
m_iStream.close();
|
||||
}
|
||||
m_iStream.open(fsFilePath, std::ios::binary | std::ios::in || std::ios::ate);
|
||||
m_iStream.open(fsFilePath, std::ios::binary | std::ios::in);
|
||||
if (!m_iStream.is_open() || !m_iStream.good())
|
||||
{
|
||||
m_eCurrentMode = Mode_t::NONE;
|
||||
return false;
|
||||
}
|
||||
|
||||
m_nSize = m_iStream.tellg();
|
||||
m_iStream.seekg(0, std::ios::beg);
|
||||
|
||||
ComputeFileSize();
|
||||
return true;
|
||||
|
||||
case Mode_t::WRITE:
|
||||
@ -96,6 +94,18 @@ void CIOStream::Flush()
|
||||
m_oStream.flush();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: computes the input file size
|
||||
//-----------------------------------------------------------------------------
|
||||
void CIOStream::ComputeFileSize()
|
||||
{
|
||||
m_nSize = m_iStream.tellg();
|
||||
m_iStream.seekg(0, std::ios::end);
|
||||
m_nSize = m_iStream.tellg() - m_nSize;
|
||||
m_iStream.seekg(0, std::ios::beg);
|
||||
m_iStream.clear();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: gets the position of the current character in the stream
|
||||
//-----------------------------------------------------------------------------
|
||||
|
@ -18,6 +18,8 @@ public:
|
||||
void Close();
|
||||
void Flush();
|
||||
|
||||
void ComputeFileSize();
|
||||
|
||||
std::streampos GetPosition();
|
||||
void SetPosition(std::streampos nOffset);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user