123
This commit is contained in:
40
ResourceCompilerPC/AutoFile.h
Normal file
40
ResourceCompilerPC/AutoFile.h
Normal file
@@ -0,0 +1,40 @@
|
||||
|
||||
class CAutoFile
|
||||
{
|
||||
FILE* m_f;
|
||||
public:
|
||||
CAutoFile (const char* szName, const char* szMode)
|
||||
{
|
||||
m_f = fopen (szName, szMode);
|
||||
}
|
||||
~CAutoFile ()
|
||||
{
|
||||
if (m_f)
|
||||
fclose (m_f);
|
||||
}
|
||||
|
||||
long GetSize()
|
||||
{
|
||||
if (fseek (m_f, 0, SEEK_END))
|
||||
return -1;
|
||||
|
||||
long nSize = ftell (m_f);
|
||||
|
||||
if (fseek(m_f, 0, SEEK_SET))
|
||||
return -1;
|
||||
|
||||
return nSize;
|
||||
}
|
||||
|
||||
bool Read (void* pData, unsigned nSize)
|
||||
{
|
||||
return (1 == fread (pData, nSize, 1, m_f));
|
||||
}
|
||||
|
||||
bool isEof()
|
||||
{
|
||||
return feof(m_f)?true:false;
|
||||
}
|
||||
|
||||
operator FILE*() {return m_f;}
|
||||
};
|
||||
Reference in New Issue
Block a user