36 CMappedFileReader(
void) : m_readPos(0), m_fileSize(0), m_pView(NULL), m_hFile(INVALID_HANDLE_VALUE), m_hMapping(NULL)
53 bool Open(LPCTSTR fileName)
56 m_hFile = ::CreateFile(fileName, GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
57 if ( m_hFile != INVALID_HANDLE_VALUE )
59 m_fileSize = ::GetFileSize(m_hFile, NULL);
60 m_hMapping = ::CreateFileMapping(m_hFile, NULL, PAGE_READONLY, 0, 0, NULL);
61 if ( m_hMapping != NULL )
63 m_pView =
static_cast<const BYTE*
>(::MapViewOfFile(m_hMapping, FILE_MAP_READ, 0, 0, 0));
64 if ( m_pView != NULL )
66 m_fileName = fileName;
89 if ( m_pView != NULL )
91 ::UnmapViewOfFile(m_pView);
94 if ( m_hMapping != NULL )
96 ::CloseHandle(m_hMapping);
99 if ( m_hFile != INVALID_HANDLE_VALUE)
101 ::CloseHandle(m_hFile);
102 m_hFile = INVALID_HANDLE_VALUE;
116 return m_pView != NULL;
139 LONGLONG l = m_fileSize;
140 LONGLONG p = llOffset;
158 m_readPos =
static_cast<INDEX
>(p);
169 virtual size_t Read(
size_t size, LPVOID _P)
const
172 size_t l = m_fileSize - m_readPos;
177 MemCopy(
static_cast<BYTE*
>(_P), &m_pView[m_readPos], s);
200 if ( index < m_fileSize )
202 return m_pView[index];
213 mutable INDEX m_readPos;
virtual LONGLONG Seek(LONGLONG llOffset, ESeekMode eSeek=TOP) const
[操作] シーク.
CMappedFileReader(void)
コンストラクタ
virtual size_t Read(size_t size, LPVOID _P) const
[取得] 読み込み
const BYTE * Refer(void) const
[参照] データアドレス参照.
BYTE operator[](INDEX index) const
[取得] データ取得.
virtual LONGLONG GetSize(void) const
[取得] サイズ取得
virtual bool CanRead(void) const
[確認] 読み込み可能か
virtual LPCTSTR GetOpenName(void) const
[取得] オープン名取得
~CMappedFileReader(void)
デストラクタ
virtual void Close(void)
[操作] クローズ
bool Open(LPCTSTR fileName)
[操作] オープン
void MemCopy(T *_pDst, const void *pSrc, size_t len)
[複製] メモリコピー