LArSoft  v06_85_00
Liquid Argon Software toolkit - http://larsoft.org/
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 ()
 

Private Attributes

HANDLE m_hFile
 
HANDLE m_hFileMapping
 
PVOID m_pMemoryMappedFileBase
 
DWORD m_cbFile
 
errMMF m_errCode
 

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.

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;
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  {
219  return;
220  }
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;
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;
242  return;
243  }
245 }
PVOID m_pMemoryMappedFileBase
Definition: LibSymbolInfo.h:80
DWORD GetFileSize(void)
Definition: LibSymbolInfo.h:72
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
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 
260 }
PVOID m_pMemoryMappedFileBase
Definition: LibSymbolInfo.h:80
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.

Referenced by CLibSymbolInfo::Dump().

71 { return m_pMemoryMappedFileBase; }
PVOID m_pMemoryMappedFileBase
Definition: LibSymbolInfo.h:80
PVOID MEMORY_MAPPED_FILE::GetBase ( void  )
inline

Definition at line 86 of file genwindef.cc.

86 { return m_pMemoryMappedFileBase; }
PVOID m_pMemoryMappedFileBase
Definition: LibSymbolInfo.h:80
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.

References errMMF_NoError.

Referenced by CLibSymbolInfo::Dump().

BOOL MEMORY_MAPPED_FILE::IsValid ( void  )
inline

Definition at line 88 of file genwindef.cc.

References errMMF_NoError.

Member Data Documentation

DWORD MEMORY_MAPPED_FILE::m_cbFile
private

Definition at line 81 of file LibSymbolInfo.h.

errMMF MEMORY_MAPPED_FILE::m_errCode
private

Definition at line 82 of file LibSymbolInfo.h.

HANDLE MEMORY_MAPPED_FILE::m_hFile
private

Definition at line 78 of file LibSymbolInfo.h.

HANDLE MEMORY_MAPPED_FILE::m_hFileMapping
private

Definition at line 79 of file LibSymbolInfo.h.

PVOID MEMORY_MAPPED_FILE::m_pMemoryMappedFileBase
private

Definition at line 80 of file LibSymbolInfo.h.


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