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

/home/jeroen/FOX/fox/fox-1.7.33/include/FXMemMap.h
00001 /********************************************************************************
00002 *                                                                               *
00003 *                      M e m o r y   M a p p e d   F i l e                      *
00004 *                                                                               *
00005 *********************************************************************************
00006 * Copyright (C) 2004,2012 by Jeroen van der Zijp.   All Rights Reserved.        *
00007 *********************************************************************************
00008 * This library is free software; you can redistribute it and/or modify          *
00009 * it under the terms of the GNU Lesser General Public License as published by   *
00010 * the Free Software Foundation; either version 3 of the License, or             *
00011 * (at your option) any later version.                                           *
00012 *                                                                               *
00013 * This library is distributed in the hope that it will be useful,               *
00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of                *
00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                 *
00016 * GNU Lesser General Public License for more details.                           *
00017 *                                                                               *
00018 * You should have received a copy of the GNU Lesser General Public License      *
00019 * along with this program.  If not, see <http://www.gnu.org/licenses/>          *
00020 ********************************************************************************/
00021 #ifndef FXMEMMAP_H
00022 #define FXMEMMAP_H
00023 
00024 
00025 #ifndef FXFILE_H
00026 #include "FXFile.h"
00027 #endif
00028 
00029 namespace FX {
00030 
00031 
00040 class FXAPI FXMemMap : public FXFile {
00041 private:
00042   FXInputHandle maphandle;      // Handle for the map
00043   FXuchar*      mapbase;        // Memory base where it is mapped
00044   FXlong        mapoffset;      // Offset of the map
00045   FXlong        mapposition;    // Position in file
00046   FXival        maplength;      // Length of the map
00047 private:
00048   FXMemMap(const FXMemMap&);
00049   FXMemMap &operator=(const FXMemMap&);
00050 public:
00051 
00053   FXMemMap();
00054 
00056   void* openMap(const FXString& filename,FXlong off=0,FXival len=-1L,FXuint m=FXIO::Reading,FXuint p=FXIO::AllReadWrite);
00057 
00059   void* openMap(FXInputHandle h,FXlong off=0,FXival len=-1L,FXuint m=FXIO::Reading);
00060 
00062   void *map(FXlong off=0,FXival len=-1L);
00063 
00065   void* base() const { return mapbase; }
00066 
00068   FXival length() const { return maplength; }
00069 
00071   FXlong offset() const { return mapoffset; }
00072 
00074   virtual FXlong position() const;
00075 
00077   virtual FXlong position(FXlong off,FXuint from=FXIO::Begin);
00078 
00080   void* unmap();
00081 
00083   virtual FXival readBlock(void* data,FXival count);
00084 
00086   virtual FXival writeBlock(const void* data,FXival count);
00087 
00089   virtual FXbool flush();
00090 
00092   virtual FXbool close();
00093 
00095   ~FXMemMap();
00096   };
00097 
00098 
00099 }
00100 
00101 #endif

Copyright © 1997-2011 Jeroen van der Zijp