XFile.h
上传用户:maryhy001
上传日期:2007-05-02
资源大小:2317k
文件大小:1k
- // XFile.h: interface for the CXFile class.
- //
- //////////////////////////////////////////////////////////////////////
- #if !defined(AFX_XFILE_H__3421850F_329D_4FF9_AE44_D1A1FA5721FD__INCLUDED_)
- #define AFX_XFILE_H__3421850F_329D_4FF9_AE44_D1A1FA5721FD__INCLUDED_
- #if _MSC_VER > 1000
- #pragma once
- #endif // _MSC_VER > 1000
- //file seek position flag.
- typedef enum { fpbegin = 0, fpend, fpcur } FILE_POS;
- //file open mode.
- typedef enum { fomOpenBirany = ios_base::binary,
- fomOpenForRead = ios_base::in,
- fomOpenForWrite = ios_base::out,
- fomCreateAlways = ios_base::trunc | fomOpenForWrite | fomOpenForRead,
- } FILE_OPNMODE;
- class NETLIBDLLEXPORT CXFile
- {
- public:
- CXFile();
- virtual ~CXFile();
- //create or open file.
- bool Open(const char *lpszFilename, int fom = fomOpenForRead | fomOpenBirany);
- void Close();
- //determine the file whether is opened / eof
- bool IsOpened();
- bool Eof();
- //read and write the file buffer.
- int Read(void *lpBuf, size_t nSize);
- void Write(const void *lpBuf, size_t nSize);
- //get the file information...
- ulong GetSize();
- //get the file name.
- string &GetFileName();
- //seek operation...
- ulong Seek(int noffset = 0, FILE_POS fp = fpcur);
- private:
- fstream m_ioStream; //file stream object...
- string m_strfilename; //file name string text...
- };
- #endif // !defined(AFX_XFILE_H__3421850F_329D_4FF9_AE44_D1A1FA5721FD__INCLUDED_)