Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members

FXMemMap.h
1 /********************************************************************************
2 * *
3 * M e m o r y M a p p e d F i l e *
4 * *
5 *********************************************************************************
6 * Copyright (C) 2004,2022 by Jeroen van der Zijp. All Rights Reserved. *
7 *********************************************************************************
8 * This library is free software; you can redistribute it and/or modify *
9 * it under the terms of the GNU Lesser General Public License as published by *
10 * the Free Software Foundation; either version 3 of the License, or *
11 * (at your option) any later version. *
12 * *
13 * This library is distributed in the hope that it will be useful, *
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
16 * GNU Lesser General Public License for more details. *
17 * *
18 * You should have received a copy of the GNU Lesser General Public License *
19 * along with this program. If not, see <http://www.gnu.org/licenses/> *
20 ********************************************************************************/
21 #ifndef FXMEMMAP_H
22 #define FXMEMMAP_H
23 
24 #ifndef FXFILE_H
25 #include "FXFile.h"
26 #endif
27 
28 namespace FX {
29 
30 
39 class FXAPI FXMemMap : public FXFile {
40 private:
41  FXInputHandle maphandle; // Handle for the map
42  FXuchar* mapbase; // Memory base where it is mapped
43  FXlong mapoffset; // Offset of the map
44  FXival maplength; // Length of the map
45 private:
46  FXMemMap(const FXMemMap&);
47  FXMemMap &operator=(const FXMemMap&);
48 public:
49 
51  FXMemMap();
52 
54  void* openMap(const FXString& filename,FXlong off=0,FXival len=-1L,FXuint m=FXIO::Reading,FXuint p=FXIO::AllReadWrite);
55 
57  void* openMap(FXInputHandle h,FXlong off=0,FXival len=-1L,FXuint m=FXIO::Reading);
58 
60  void *map(FXlong off=0,FXival len=-1L);
61 
63  void* base() const { return mapbase; }
64 
66  FXival length() const { return maplength; }
67 
69  FXlong offset() const { return mapoffset; }
70 
72  virtual FXlong position() const;
73 
75  virtual FXlong position(FXlong off,FXuint from=FXIO::Begin);
76 
78  void* unmap();
79 
81  virtual FXival readBlock(void* ptr,FXival count);
82 
84  virtual FXival writeBlock(const void* ptr,FXival count);
85 
87  virtual FXbool flush();
88 
90  virtual FXbool close();
91 
93  ~FXMemMap();
94  };
95 
96 
97 }
98 
99 #endif
Execute permission for all.
Definition: FXIO.h:94
FXival length() const
Obtain length of the map.
Definition: FXMemMap.h:66
FXlong offset() const
Obtain offset of the map.
Definition: FXMemMap.h:69
Child process can inherit handle.
Definition: FXIO.h:58
void * base() const
Return pointer to memory area.
Definition: FXMemMap.h:63
Definition: FX4Splitter.h:28
Low level file access.
Definition: FXFile.h:34
A Memory Map provides a view of a file as an array of memory; this allows the file itself to be used ...
Definition: FXMemMap.h:39
FXString provides essential string manipulation capabilities in FOX.
Definition: FXString.h:42

Copyright © 1997-2022 Jeroen van der Zijp