|
1 /* |
|
2 * Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of the License "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #if !defined(__MEMMAPUTILS_H__) |
|
20 #define __MEMMAPUTILS_H__ |
|
21 |
|
22 #ifdef WIN32 |
|
23 #include <windows.h> |
|
24 #include <io.h> |
|
25 #endif |
|
26 |
|
27 #include <fcntl.h> |
|
28 #include <sys/types.h> |
|
29 #include <sys/stat.h> |
|
30 #include <stdio.h> |
|
31 #include <string> |
|
32 #include <fstream> |
|
33 |
|
34 #include "h_utl.h" |
|
35 |
|
36 typedef std::string String; |
|
37 typedef std::ofstream Ofstream; |
|
38 |
|
39 const int KStatTrue = 1; |
|
40 const int KStatFalse = 0; |
|
41 |
|
42 /** |
|
43 class MemmapUtils |
|
44 |
|
45 @internalComponent |
|
46 @released |
|
47 */ |
|
48 class MemmapUtils |
|
49 { |
|
50 private: |
|
51 // Memory map file descriptor |
|
52 int iHFile; |
|
53 |
|
54 #ifdef WIN32 |
|
55 // Windows specific Memory map object handle |
|
56 HANDLE iHMMFile; |
|
57 #endif |
|
58 // Map file name |
|
59 String iMapFileName; |
|
60 |
|
61 public: |
|
62 MemmapUtils(); |
|
63 ~MemmapUtils(); |
|
64 |
|
65 // Generate temporary file name |
|
66 void GetMapFileName(String& aFile); |
|
67 |
|
68 // Create the memory map |
|
69 void* OpenMemMapPointer(unsigned long aOffset, unsigned long aSize); |
|
70 // Close the memory map |
|
71 int CloseMemMapPointer(void* aData, unsigned long aSize); |
|
72 // Open the file for memory mapping |
|
73 int OpenMapFile(); |
|
74 // Close the memory mapped file |
|
75 void CloseMapFile(); |
|
76 // Delete the memory mapped file |
|
77 void DeleteMapFile(); |
|
78 |
|
79 int IsMapFileOpen(); |
|
80 |
|
81 // Windows specific file mapping object |
|
82 int CreateFileMapObject(unsigned long aSize); |
|
83 void CloseFileMapObject(); |
|
84 }; |
|
85 |
|
86 #endif //__MEMMAPUTILS_H__ |