rendered paste body#ifndef fileio_hpp_
#define fileio_hpp_
#include <cstdio>
class FileIO
{
private:
FILE *pFile;
public:
bool Open(char *cpFileName);
void Close();
bool Read(int iAmount,char *cpDataBuffer,int iStartPoint);
bool Write(char *cpDataBuffer,int iStartPoint);
bool Remove(char *cpFileName);
bool Rename(char *cpOldFileName,char *cpNewFileName);
};
bool FileIO::Open(char *cpFileName)
{
if(!cpFileName)
return false;
fopen_s(&pFile,cpFileName,"a+");
return true;
}
void FileIO::Close()
{
fclose(pFile);
}
bool FileIO::Read(int iAmount,char *cpDataBuffer,int iStartPoint)
{
if(!pFile)
return false;
if(fseek(pFile,iStartPoint,SEEK_SET))
return false;
else
fgets(cpDataBuffer,iAmount,pFile);
return true;
}
bool FileIO::Write(char *cpDataBuffer,int iStartPoint)
{
if(!pFile)
return false;
if(fseek(pFile,iStartPoint,SEEK_SET))
return false;
else
fputs(cpDataBuffer,pFile);
return true;
}
bool FileIO::Remove(char* cpFileName)
{
if(!remove(cpFileName))
return false;
else return true;
}
bool FileIO::Rename(char *cpOldFileName, char *cpNewFileName)
{
if(!rename(cpOldFileName,cpNewFileName))
return false;
else
return true;
}
#endif