#if defined(__FLAT__) #ifndef _COMMON_FILEMAP_HPP_ #define _COMMON_FILEMAP_HPP_ #ifndef _COMMON_STRING_HPP_ #include #endif class FileHandle; class FileMap { public: friend class PureViewOfFile; enum MapMessage{ShutDown=0x02}; enum Paging{ReadOnly=PAGE_READONLY,ReadWrite=PAGE_READWRITE,WriteCopy=PAGE_WRITECOPY}; enum Protection{Commit=SEC_COMMIT,Image=SEC_IMAGE,NoCache=SEC_NOCACHE,Reserve=SEC_RESERVE}; FileMap(void); FileMap(String mapFileName,DWORD maxExtentHigh,DWORD maxExtentLow,Paging paging=ReadWrite,Protection protection=Commit); FileMap(const FileHandle &someFileHandle); virtual ~FileMap(); WORD create(const FileHandle &someFileHandle); WORD create(String mapName,DWORD maxExtentHigh,DWORD maxExtentLow,Paging paging,Protection protection,HANDLE hMapFile=(HANDLE)0xFFFFFFFF); BOOL open(const String &strName,DWORD maxExtentHigh,DWORD maxExtentLow,Paging paging=ReadWrite,Protection protection=Commit,DWORD access=FILE_MAP_ALL_ACCESS,BOOL inherit=TRUE); DWORD maxExtentLow(void)const; DWORD maxExtentHigh(void)const; Paging paging(void)const; Protection protection(void)const; HANDLE getHandle(void)const; WORD isOkay(void)const; private: FileMap(const FileMap &someFileMap); operator HANDLE(void)const; void destroyMap(void); void maxExtentLow(DWORD maxExtentLow); void maxExtentHigh(DWORD maxExtentHigh); Paging mPaging; Protection mProtection; DWORD mMaxExtentHigh; DWORD mMaxExtentLow; HANDLE mhFileHandle; }; inline WORD FileMap::isOkay(void)const { return (mhFileHandle?TRUE:FALSE); } inline FileMap::operator HANDLE(void)const { return mhFileHandle; } inline DWORD FileMap::maxExtentLow(void)const { return mMaxExtentLow; } inline void FileMap::maxExtentLow(DWORD maxExtentLow) { mMaxExtentLow=maxExtentLow; } inline DWORD FileMap::maxExtentHigh(void)const { return mMaxExtentHigh; } inline void FileMap::maxExtentHigh(DWORD maxExtentHigh) { mMaxExtentHigh=maxExtentHigh; } inline FileMap::Paging FileMap::paging(void)const { return mPaging; } inline FileMap::Protection FileMap::protection(void)const { return mProtection; } inline FileMap::~FileMap() { destroyMap(); } inline HANDLE FileMap::getHandle(void)const { return mhFileHandle; } inline void FileMap::destroyMap(void) { if(!mhFileHandle)return; ::CloseHandle(mhFileHandle); mhFileHandle=0; } #endif #endif