#include <CFileMap.h>
Inheritance diagram for AxPipe::CSinkMemFile:
Public Member Functions | |
CSinkMemFile * | Init (const TCHAR *szFileName, size_t cbChunk=64 *1024) |
Set file and chunk size. | |
CSinkMemFile () | |
Initialize member variables etc. | |
virtual | ~CSinkMemFile () |
Additional destruction necessary... | |
Protected Member Functions | |
HANDLE | GetHandle () |
Get the handle to the opened file. | |
bool | OutClose () |
Close the file, as well as all mappings, set end of file etc. | |
CSeg * | OutGetSeg (size_t cb) |
Get a writeable segment, mapped to the output file if possible. | |
void | Out (CSeg *pSeg) |
Write a segment to the file, optimizing the case where it already is a mapping. | |
bool | OutOpen () |
Open the file named in Init() for output. | |
Private Attributes | |
HANDLE | m_hFile |
The opened file. | |
HANDLE | m_hMapping |
The mapping of the file. | |
size_t | m_cbChunk |
The chunk size we send down stream. | |
longlong | m_cbFileSize |
The length of the file in bytes. | |
longlong | m_cbStreamPos |
The next file position to read a chunk from. | |
_TCHAR * | m_szFileName |
The provided file name, new[]'d and delete[]'d here. | |
longlong | m_cbInPos |
The file pointer position to get the next segment to write to. | |
longlong | m_cbOutPos |
The file pointer position to write the next output to. | |
longlong | m_cbMappingSize |
The size of the current mapping - changed dynamically. | |
CRITICAL_SECTION | m_CritSect |
Threading protection for certain code sections. |
Definition at line 102 of file CFileMap.h.
|
Get the handle to the opened file.
Definition at line 232 of file CFileMap.cpp. References m_hFile. |
|
Set file and chunk size.
Definition at line 241 of file CFileMap.cpp. References _TCHAR, m_cbChunk, and m_szFileName. |
|
Write a segment to the file, optimizing the case where it already is a mapping. Write a segment to the file by copying into a memory mapped segment, unless we're already such a segment, in which case we actually need do nothing except keep track of the length of valid data 'written'.
Implements AxPipe::CSink. Definition at line 346 of file CFileMap.cpp. References _T, AxPipe::ERROR_CODE_GENERIC, AxPipe::CSegMap::GetPos(), AxPipe::CSeg::Len(), m_cbOutPos, m_CritSect, m_hMapping, AxPipe::MapUserView(), OutGetSeg(), AxPipe::CSeg::PtrRd(), AxPipe::CSeg::PtrWr(), AxPipe::CSeg::Release(), AxPipe::CSeg::RTClassId(), and AxPipe::CError::SetError(). |
|
Close the file, as well as all mappings, set end of file etc. Check for errors with GetErrorCode()
Reimplemented from AxPipe::CSink. Definition at line 253 of file CFileMap.cpp. References _T, AxPipe::ERROR_CODE_GENERIC, m_cbOutPos, m_hFile, m_hMapping, and AxPipe::CError::SetError(). |
|
Get a writeable segment, mapped to the output file if possible. Map a request for an output segment directly to the output file. If necessary, re-create a mapping to a possibly extended file. For this to be useful, the upstream caller must get segments in the same sequence that they are output, and also keep them the same size, i.e. not get a segment and then change the CSeg::Len() or CSeg::Drop() bytes off it. In fact using CSeg::Drop() will cause undefined effects. Shortening is possible, but strongly recommended against, as it will make the code quite inefficient.
Reimplemented from AxPipe::CSink. Definition at line 300 of file CFileMap.cpp. References _T, AxPipe::ERROR_CODE_GENERIC, AxPipe::longlong, m_cbInPos, m_cbMappingSize, m_cbOutPos, m_CritSect, m_hFile, m_hMapping, AxPipe::MapUserView(), and AxPipe::CError::SetError(). Referenced by Out(). |
|
Open the file named in Init() for output. Check for errors with GetErrorCode().
Reimplemented from AxPipe::CSink. Definition at line 399 of file CFileMap.cpp. References _T, AxPipe::ERROR_CODE_GENERIC, m_cbInPos, m_cbMappingSize, m_cbOutPos, m_hFile, m_szFileName, and AxPipe::CError::SetError(). |