1
0

Replaced most FILE operations with a cFile object

git-svn-id: http://mc-server.googlecode.com/svn/trunk@196 0a769ca7-a7f5-676a-18bf-c427514a06d6
This commit is contained in:
madmaxoft@gmail.com
2012-01-30 22:48:38 +00:00
parent b834841aa1
commit f4583fda98
7 changed files with 219 additions and 160 deletions

View File

@@ -198,3 +198,34 @@ int cFile::Tell (void) const
/// Returns the size of file, in bytes, or -1 for failure; asserts if not open
int cFile::GetSize(void) const
{
assert(IsOpen());
if (!IsOpen())
{
return -1;
}
int CurPos = ftell(m_File);
if (CurPos < 0)
{
return -1;
}
if (fseek(m_File, 0, SEEK_END) != 0)
{
return -1;
}
int res = ftell(m_File);
if (fseek(m_File, CurPos, SEEK_SET) != 0)
{
return -1;
}
return res;
}