?? hstdfile.h
字號(hào):
// HStdFile.h: interface for the HStdFile class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_HSTDFILE_H__557FCDD5_EEB1_4421_87BC_D423D0457FBA__INCLUDED_)
#define AFX_HSTDFILE_H__557FCDD5_EEB1_4421_87BC_D423D0457FBA__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
//文件名 : HStdFile.h
//功能 : 簡(jiǎn)單的C庫(kù)文件操作
//創(chuàng)建 : 2004.4.8
//作者 : 韓國(guó)靜
//
#include "stdio.h"
#include "./public/UniType.h"
class HStdFile
{
FILE * m_hFile;
public:
UNI_BOOL IsOpened(){return m_hFile?UNI_TRUE:UNI_FALSE;}
void Close()
{
if(this->m_hFile)
{
fclose(m_hFile);
m_hFile=UNI_NULL;
}
};
UNI_BOOL GetFileSize(UNI_DWORD &dwFileSize)
{
if(m_hFile)
{
long pos=ftell(this->m_hFile );
if(0==fseek(this->m_hFile,0,SEEK_END))
{
dwFileSize=(UNI_DWORD)ftell(m_hFile);
fseek(m_hFile,pos,SEEK_SET);
return UNI_TRUE;
}
}
return UNI_FALSE;
};
UNI_DWORD Write(void *pInBuf,UNI_DWORD dwSizeWrite)
{
if(pInBuf==UNI_NULL)
return 0;
return (UNI_DWORD)fwrite(pInBuf,1,dwSizeWrite,this->m_hFile);
};
UNI_DWORD WriteAt(void *pInBuf,UNI_DWORD dwSizeWrite,UNI_INT pos)
{
if(pInBuf!=UNI_NULL && dwSizeWrite!=0 && pos==fseek(m_hFile,pos,SEEK_SET))
{
return (UNI_DWORD)fwrite(pInBuf,1,dwSizeWrite,this->m_hFile);
}
return 0;
};
UNI_DWORD Read(void *pOutBuf,UNI_DWORD dwSizeRead)
{
if(pOutBuf==UNI_NULL)
return UNI_FALSE;
return (UNI_DWORD)fread(pOutBuf,1,dwSizeRead,this->m_hFile);
};
UNI_DWORD ReadAt(void *pOutBuf,UNI_DWORD dwSizeRead,UNI_INT pos)
{
if(pOutBuf!=UNI_NULL && dwSizeRead!=0 && pos==fseek(m_hFile,pos,SEEK_SET))
{
return (UNI_DWORD)fread(pOutBuf,1,dwSizeRead,this->m_hFile);
}
return 0;
}
UNI_BOOL CreateNew(char *pFileName)
{
Close();
m_hFile=fopen(pFileName,"w+b");
return m_hFile?UNI_TRUE:UNI_FALSE;
};
UNI_BOOL OpenForAppend(char *pFileName)
{
Close();
m_hFile=fopen(pFileName,"ab");
return m_hFile?UNI_TRUE:UNI_FALSE;
};
UNI_BOOL OpenForReadWrite(char *pFileName)
{
Close();
m_hFile=fopen(pFileName,"r+b");
return m_hFile?UNI_TRUE:UNI_FALSE;
};
UNI_BOOL OpenForRead(char *pFileName)
{
Close();
m_hFile=fopen(pFileName,"rb");
return m_hFile?UNI_TRUE:UNI_FALSE;
};
HStdFile()
{
m_hFile=UNI_NULL;
};
virtual ~HStdFile()
{
Close();
};
};
#endif // !defined(AFX_HSTDFILE_H__557FCDD5_EEB1_4421_87BC_D423D0457FBA__INCLUDED_)
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -