FXMemMap.h

Go to the documentation of this file.
00001 #ifdef FX_FOXCOMPAT
00002 
00003 /********************************************************************************
00004 *                                                                               *
00005 *                      M e m o r y   M a p p e d   F i l e                      *
00006 *                                                                               *
00007 *********************************************************************************
00008 * Copyright (C) 2004,2006 by Jeroen van der Zijp.   All Rights Reserved.        *
00009 *********************************************************************************
00010 * This library is free software; you can redistribute it and/or                 *
00011 * modify it under the terms of the GNU Lesser General Public                    *
00012 * License as published by the Free Software Foundation; either                  *
00013 * version 2.1 of the License, or (at your option) any later version.            *
00014 *                                                                               *
00015 * This library is distributed in the hope that it will be useful,               *
00016 * but WITHOUT ANY WARRANTY; without even the implied warranty of                *
00017 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU             *
00018 * Lesser General Public License for more details.                               *
00019 *                                                                               *
00020 * You should have received a copy of the GNU Lesser General Public              *
00021 * License along with this library; if not, write to the Free Software           *
00022 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.    *
00023 *********************************************************************************
00024 * $Id: FXMemMap.h,v 1.8 2006/01/22 17:58:06 fox Exp $                           *
00025 ********************************************************************************/
00026 #ifndef FXMEMMAP_H
00027 #define FXMEMMAP_H
00028 
00029 namespace FX {
00030 
00031 
00040 class FXAPI FXMemMap {
00041 private:
00042   void*         mapbase;        // Memory base where it is mapped
00043   long          maplength;      // Length of the map
00044   long          mapoffset;      // Offset of the map
00045   FXInputHandle handle;         // Handle for the map
00046   FXInputHandle file;           // Handle for the file
00047 private:
00048   FXMemMap(const FXMemMap&);
00049   FXMemMap &operator=(const FXMemMap&);
00050 public:
00051 
00053   enum {
00054     NONE  = 0,          
00055     READ  = 1,          
00056     WRITE = 2,          
00057     EXEC  = 4,          
00058     TRUNC = 8           
00059     };
00060 
00062   enum {
00063     PRIV = 0,        
00064     SHAR = 1         
00065     };
00066 
00067 public:
00068 
00070   FXMemMap();
00071 
00073   void* mapFile(const FXString& filename,long off=0,long len=-1L,FXuint access=READ,FXuint share=PRIV);
00074 
00076   void* unmap();
00077 
00079   void sync();
00080 
00082   void* base() const { return mapbase; }
00083 
00085   long length() const { return maplength; }
00086 
00088   long offset() const { return mapoffset; }
00089 
00091   ~FXMemMap();
00092   };
00093 
00094 
00095 }
00096 
00097 #endif
00098 #endif

(C) 2002-2009 Niall Douglas. Some parts (C) to assorted authors.
Generated on Fri Nov 20 18:31:23 2009 for TnFOX by doxygen v1.4.7