00001 #ifndef CFILEMAP_H
00002 #define CFILEMAP_H
00003
00043 #include "AxPipe.h"
00044
00045 namespace AxPipe {
00058 class CSegMap : public CSeg {
00059 longlong m_llPos;
00060 void *m_pView;
00061 void *m_pOwner;
00062
00063 public:
00065 CSegMap(void *pOwner, size_t cb, void *pv, void *pView, longlong llPos, bool fReadOnly = false);
00066 virtual ~CSegMap();
00067 longlong GetPos();
00068
00069 public:
00070 static void *ClassId();
00071 virtual void *RTClassId();
00072 bool IsOwner(void *pOwner);
00073 };
00074
00076 class CSourceMemFile : public CSource {
00077 HANDLE m_hFile,
00078 m_hMapping;
00079 size_t m_cbChunk;
00080 longlong m_cbFileSize,
00081 m_cbStreamPos;
00082 _TCHAR *m_szFileName;
00083
00084 protected:
00085 HANDLE GetHandle();
00086
00087 public:
00088
00090 CSourceMemFile *Init(const _TCHAR *szFileName, size_t cbChunk = 64*1024);
00091 CSourceMemFile();
00092
00093 protected:
00094 bool OutOpen();
00095 bool OutClose(void);
00096 CSeg *In();
00097 };
00098
00100 typedef CThread<CSourceMemFile> CTSourceMemFile;
00101
00103 class CSinkMemFile : public CSink {
00104 HANDLE m_hFile,
00105 m_hMapping;
00106 size_t m_cbChunk;
00107 longlong m_cbFileSize,
00108 m_cbStreamPos;
00109 _TCHAR *m_szFileName;
00110 longlong m_cbInPos,
00111 m_cbOutPos,
00112 m_cbMappingSize;
00113 CRITICAL_SECTION m_CritSect;
00114
00115 protected:
00116 HANDLE GetHandle();
00117
00118 public:
00120 CSinkMemFile *Init(const TCHAR *szFileName, size_t cbChunk = 64*1024);
00121 CSinkMemFile();
00122 virtual ~CSinkMemFile();
00123
00124 protected:
00125 bool OutClose();
00126 CSeg *OutGetSeg(size_t cb);
00127 void Out(CSeg *pSeg);
00128 bool OutOpen();
00129 };
00130
00132 typedef CThread<CSinkMemFile> CTSinkMemFile;
00133
00134 }
00135 #endif CFILEMAP_H