Geant4  10.03.p03
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 ()
 
 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 65 of file LibSymbolInfo.h.

Constructor & Destructor Documentation

MEMORY_MAPPED_FILE::MEMORY_MAPPED_FILE ( PSTR  pszFileName)

Definition at line 201 of file LibSymbolInfo.cpp.

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:72
MEMORY_MAPPED_FILE::~MEMORY_MAPPED_FILE ( void  )

Definition at line 247 of file LibSymbolInfo.cpp.

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 }
MEMORY_MAPPED_FILE::MEMORY_MAPPED_FILE ( PSTR  pszFileName)
MEMORY_MAPPED_FILE::~MEMORY_MAPPED_FILE ( void  )

Member Function Documentation

PVOID MEMORY_MAPPED_FILE::GetBase ( void  )
inline

Definition at line 71 of file LibSymbolInfo.h.

71 { return m_pMemoryMappedFileBase; }

Here is the caller graph for this function:

PVOID MEMORY_MAPPED_FILE::GetBase ( void  )
inline

Definition at line 86 of file genwindef.cc.

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

Definition at line 74 of file LibSymbolInfo.h.

74 { return m_errCode; }
errMMF MEMORY_MAPPED_FILE::GetErrorType ( )
inline

Definition at line 89 of file genwindef.cc.

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

Definition at line 72 of file LibSymbolInfo.h.

72 { return m_cbFile; }
DWORD MEMORY_MAPPED_FILE::GetFileSize ( void  )
inline

Definition at line 87 of file genwindef.cc.

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

Definition at line 73 of file LibSymbolInfo.h.

73 { return errMMF_NoError == m_errCode; }

Here is the caller graph for this function:

BOOL MEMORY_MAPPED_FILE::IsValid ( void  )
inline

Definition at line 88 of file genwindef.cc.

88 { return errMMF_NoError == m_errCode; }

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