Last active
August 29, 2015 13:57
-
-
Save poppycocker/9500621 to your computer and use it in GitHub Desktop.
StdioFile64
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "StdAfx.h" | |
class CStdioFile64 : public CStdioFile | |
{ | |
public: | |
CStdioFile64(LPCTSTR lpszFileName, UINT nOpenFlags) : CStdioFile(lpszFileName, nOpenFlags){} | |
virtual ~CStdioFile64(){}; | |
ULONGLONG Seek(LONGLONG lOff, UINT nFrom); | |
ULONGLONG GetLength() const; | |
ULONGLONG GetPosition() const; | |
}; | |
ULONGLONG CStdioFile64::Seek(LONGLONG lOff, UINT nFrom) | |
{ | |
ASSERT_VALID(this); | |
ASSERT(nFrom == begin || nFrom == end || nFrom == current); | |
ASSERT(m_pStream != NULL); | |
if (_fseeki64(m_pStream, lOff, nFrom) != 0) | |
AfxThrowFileException(CFileException::badSeek, _doserrno, | |
m_strFileName); | |
return _ftelli64(m_pStream); | |
} | |
ULONGLONG CStdioFile64::GetLength() const | |
{ | |
ASSERT_VALID(this); | |
LONGLONG nCurrent, nLength; | |
int nResult; | |
nCurrent = _ftelli64(m_pStream); | |
if (nCurrent == -1) | |
AfxThrowFileException(CFileException::invalidFile, _doserrno, m_strFileName); | |
nResult = _fseeki64(m_pStream, 0, SEEK_END); | |
if (nResult != 0) | |
AfxThrowFileException(CFileException::badSeek, _doserrno, m_strFileName); | |
nLength = _ftelli64(m_pStream); | |
if (nLength == -1) | |
AfxThrowFileException(CFileException::invalidFile, _doserrno, m_strFileName); | |
nResult = _fseeki64(m_pStream, nCurrent, SEEK_SET); | |
if (nResult != 0) | |
AfxThrowFileException(CFileException::badSeek, _doserrno, m_strFileName); | |
return nLength; | |
} | |
ULONGLONG CStdioFile64::GetPosition() const | |
{ | |
ASSERT_VALID(this); | |
ASSERT(m_pStream != NULL); | |
LONGLONG pos = _ftelli64(m_pStream); | |
if (pos == -1) | |
AfxThrowFileException(CFileException::invalidFile, _doserrno, m_strFileName); | |
return pos; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment