Geant4.10
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions
MEMORY_MAPPED_FILE Class Reference

#include <LibSymbolInfo.h>

Public Member Functions

 MEMORY_MAPPED_FILE (PSTR pszFileName)
 
 ~MEMORY_MAPPED_FILE (void)
 
PVOID GetBase (void)
 
DWORD GetFileSize (void)
 
BOOL IsValid (void)
 
errMMF GetErrorType ()
 

Detailed Description

Definition at line 40 of file LibSymbolInfo.h.

Constructor & Destructor Documentation

MEMORY_MAPPED_FILE::MEMORY_MAPPED_FILE ( PSTR  pszFileName)

Definition at line 201 of file LibSymbolInfo.cpp.

References errMMF_FileMapping, errMMF_FileOpen, errMMF_MapView, and errMMF_NoError.

201  {
202 
203  //
204  // Given a filename, the constructor opens a file handle, creates a file
205  // mapping, and maps the entire file into memory.
206  //
207  m_hFile = INVALID_HANDLE_VALUE;
208  m_hFileMapping = 0;
209  m_pMemoryMappedFileBase = 0;
210  m_cbFile = 0;
211  m_errCode = errMMF_FileOpen; // Initial error code: not found
212  // First get a file handle
213  m_hFile = CreateFile(pszFileName, GENERIC_READ, FILE_SHARE_READ, NULL,
214  OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, (HANDLE)0);
215 
216  if ( m_hFile == INVALID_HANDLE_VALUE )
217  {
218  m_errCode = errMMF_FileOpen;
219  return;
220  }
221  m_cbFile = ::GetFileSize( m_hFile, 0 );
222  // Now, create a file mapping
223  m_hFileMapping = CreateFileMapping(m_hFile,NULL, PAGE_READONLY, 0, 0,NULL);
224  if ( m_hFileMapping == 0 )
225  {
226  // Oops. Something went wrong. Clean up.
227  CloseHandle(m_hFile);
228  m_hFile = INVALID_HANDLE_VALUE;
229  m_errCode = errMMF_FileMapping;
230  return;
231  }
232  m_pMemoryMappedFileBase = (PCHAR)MapViewOfFile( m_hFileMapping,
233  FILE_MAP_READ, 0, 0, 0);
234  if ( m_pMemoryMappedFileBase == 0 )
235  {
236  // Oops. Something went wrong. Clean up.
237  CloseHandle(m_hFileMapping);
238  m_hFileMapping = 0;
239  CloseHandle(m_hFile);
240  m_hFile = INVALID_HANDLE_VALUE;
241  m_errCode = errMMF_MapView;
242  return;
243  }
244  m_errCode = errMMF_NoError;
245 }
DWORD GetFileSize(void)
Definition: LibSymbolInfo.h:47
MEMORY_MAPPED_FILE::~MEMORY_MAPPED_FILE ( void  )

Definition at line 247 of file LibSymbolInfo.cpp.

References errMMF_FileOpen.

248 {
249  // Clean up everything that was created by the constructor
250  if ( m_pMemoryMappedFileBase )
251  UnmapViewOfFile( m_pMemoryMappedFileBase );
252 
253  if ( m_hFileMapping )
254  CloseHandle( m_hFileMapping );
255 
256  if ( m_hFile != INVALID_HANDLE_VALUE )
257  CloseHandle( m_hFile );
258 
259  m_errCode = errMMF_FileOpen;
260 }

Member Function Documentation

PVOID MEMORY_MAPPED_FILE::GetBase ( void  )
inline

Definition at line 46 of file LibSymbolInfo.h.

Referenced by CLibSymbolInfo::Dump().

46 { return m_pMemoryMappedFileBase; }
errMMF MEMORY_MAPPED_FILE::GetErrorType ( )
inline

Definition at line 49 of file LibSymbolInfo.h.

49 { return m_errCode; }
DWORD MEMORY_MAPPED_FILE::GetFileSize ( void  )
inline

Definition at line 47 of file LibSymbolInfo.h.

47 { return m_cbFile; }
BOOL MEMORY_MAPPED_FILE::IsValid ( void  )
inline

Definition at line 48 of file LibSymbolInfo.h.

References errMMF_NoError.

Referenced by CLibSymbolInfo::Dump().

48 { return errMMF_NoError == m_errCode; }

The documentation for this class was generated from the following files: