LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
MEMORY_MAPPED_FILE Class Reference

Public Member Functions

 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 79 of file genwindef.cc.

Constructor & Destructor Documentation

MEMORY_MAPPED_FILE::MEMORY_MAPPED_FILE ( PSTR  pszFileName)

Definition at line 288 of file genwindef.cc.

References errMMF_FileMapping, errMMF_FileOpen, errMMF_MapView, and errMMF_NoError.

288  {
289 
290  //
291  // Given a filename, the constructor opens a file handle, creates a file
292  // mapping, and maps the entire file into memory.
293  //
294  m_hFile = INVALID_HANDLE_VALUE;
295  m_hFileMapping = 0;
297  m_cbFile = 0;
298  m_errCode = errMMF_FileOpen; // Initial error code: not found
299  // First get a file handle
300  m_hFile = CreateFile(pszFileName, GENERIC_READ, FILE_SHARE_READ, NULL,
301  OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, (HANDLE)0);
302 
303  if ( m_hFile == INVALID_HANDLE_VALUE )
304  {
306  return;
307  }
309  // Now, create a file mapping
310  m_hFileMapping = CreateFileMapping(m_hFile,NULL, PAGE_READONLY, 0, 0,NULL);
311  if ( m_hFileMapping == 0 )
312  {
313  // Oops. Something went wrong. Clean up.
314  CloseHandle(m_hFile);
315  m_hFile = INVALID_HANDLE_VALUE;
317  return;
318  }
319  m_pMemoryMappedFileBase = (PCHAR)MapViewOfFile( m_hFileMapping,
320  FILE_MAP_READ, 0, 0, 0);
321  if ( m_pMemoryMappedFileBase == 0 )
322  {
323  // Oops. Something went wrong. Clean up.
324  CloseHandle(m_hFileMapping);
325  m_hFileMapping = 0;
326  CloseHandle(m_hFile);
327  m_hFile = INVALID_HANDLE_VALUE;
329  return;
330  }
332 }
PVOID m_pMemoryMappedFileBase
Definition: genwindef.cc:94
HANDLE m_hFileMapping
Definition: genwindef.cc:93
DWORD GetFileSize(void)
Definition: genwindef.cc:86
MEMORY_MAPPED_FILE::~MEMORY_MAPPED_FILE ( void  )

Definition at line 334 of file genwindef.cc.

References errMMF_FileOpen.

335 {
336  // Clean up everything that was created by the constructor
338  UnmapViewOfFile( m_pMemoryMappedFileBase );
339 
340  if ( m_hFileMapping )
341  CloseHandle( m_hFileMapping );
342 
343  if ( m_hFile != INVALID_HANDLE_VALUE )
344  CloseHandle( m_hFile );
345 
347 }
PVOID m_pMemoryMappedFileBase
Definition: genwindef.cc:94
HANDLE m_hFileMapping
Definition: genwindef.cc:93

Member Function Documentation

PVOID MEMORY_MAPPED_FILE::GetBase ( void  )
inline

Definition at line 85 of file genwindef.cc.

Referenced by CLibSymbolInfo::Dump().

85 { return m_pMemoryMappedFileBase; }
PVOID m_pMemoryMappedFileBase
Definition: genwindef.cc:94
errMMF MEMORY_MAPPED_FILE::GetErrorType ( )
inline

Definition at line 88 of file genwindef.cc.

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

Definition at line 86 of file genwindef.cc.

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

Definition at line 87 of file genwindef.cc.

References errMMF_NoError.

Referenced by CLibSymbolInfo::Dump().

87 { return errMMF_NoError == m_errCode; }

Member Data Documentation

DWORD MEMORY_MAPPED_FILE::m_cbFile
private

Definition at line 95 of file genwindef.cc.

errMMF MEMORY_MAPPED_FILE::m_errCode
private

Definition at line 96 of file genwindef.cc.

HANDLE MEMORY_MAPPED_FILE::m_hFile
private

Definition at line 92 of file genwindef.cc.

HANDLE MEMORY_MAPPED_FILE::m_hFileMapping
private

Definition at line 93 of file genwindef.cc.

PVOID MEMORY_MAPPED_FILE::m_pMemoryMappedFileBase
private

Definition at line 94 of file genwindef.cc.


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