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

plfilesrc.h

00001 /*
00002 /--------------------------------------------------------------------
00003 |
00004 |      $Id: plfilesrc.h,v 1.8 2003/11/22 13:11:34 uzadow Exp $
00005 |
00006 |      Copyright (c) 1996-2002 Ulrich von Zadow
00007 |
00008 \--------------------------------------------------------------------
00009 */
00010 
00011 #ifndef INCL_PLFILESRC
00012 #define INCL_PLFILESRC
00013 
00014 #ifndef INCL_PLDATASRC
00015 #include "pldatasrc.h"
00016 #endif
00017 
00018 #include "config.h"
00019 
00020 #include <stdio.h>
00021 
00022 class PLIProgressNotification;
00023 
00024 //! This is a class which takes a file as a source of picture data.
00025 class PLFileSource : public PLDataSource
00026 {
00027 
00028 public:
00029   //!
00030   PLFileSource
00031     ( PLIProgressNotification * pNotification = NULL
00032     );
00033 
00034   //!
00035   virtual ~PLFileSource
00036     ();
00037 
00038   //!
00039   virtual int Open
00040     ( const char * pszFName
00041     );
00042 #ifdef _WINDOWS
00043   virtual int OpenW
00044     ( const wchar_t * pszwFName
00045     );
00046 #endif
00047 
00048   //!
00049   virtual void Close
00050     ();
00051 
00052   virtual PLBYTE * ReadNBytes
00053     ( int n
00054     );
00055 
00056   //! Read but don't advance file pointer.
00057   virtual PLBYTE * GetBufferPtr
00058     ( int MinBytesInBuffer
00059     );
00060 
00061   virtual PLBYTE * ReadEverything
00062     ();
00063 
00064 private:
00065   void isBufferOk (int NumBytes);
00066 #ifdef _WINDOWS
00067   int mapFileHandle();
00068   int getLastPLError();
00069   
00070   HANDLE m_hf;    // File handle.
00071   HANDLE m_hm;    // Handle to file-mapping object.
00072 #else
00073   #ifdef HAVE_MMAP
00074   
00075   #else  
00076   bool bytesAvailable
00077     ( int n
00078     );
00079 
00080   void fillBuffer
00081     ( int n = 4096
00082     );
00083 
00084   FILE * m_pFile;
00085   PLBYTE * m_pBuffer;
00086 
00087   PLBYTE * m_pReadPos;
00088   int m_BytesReadFromFile;
00089   #endif
00090 #endif
00091   PLBYTE * m_pStartData;
00092   PLBYTE * m_pCurPos;
00093 };
00094 
00095 #endif
00096 /*
00097 /--------------------------------------------------------------------
00098 |
00099 |      $Log: plfilesrc.h,v $
00100 |      Revision 1.8  2003/11/22 13:11:34  uzadow
00101 |      Added memory-mapped file support for linux
00102 |
00103 |      Revision 1.7  2003/08/03 12:36:56  uzadow
00104 |      Added unicode support; fixed some header includes.
00105 |
00106 |      Revision 1.6  2003/08/03 12:03:20  uzadow
00107 |      Added unicode support; fixed some header includes.
00108 |
00109 |      Revision 1.5  2003/04/20 22:20:49  uzadow
00110 |      Added check for errors reading memory-mapped files.
00111 |
00112 |      Revision 1.4  2002/03/31 13:36:41  uzadow
00113 |      Updated copyright.
00114 |
00115 |      Revision 1.3  2001/10/06 22:37:08  uzadow
00116 |      Linux compatibility.
00117 |
00118 |      Revision 1.2  2001/09/16 20:57:17  uzadow
00119 |      Linux version name prefix changes
00120 |
00121 |      Revision 1.1  2001/09/16 19:03:22  uzadow
00122 |      Added global name prefix PL, changed most filenames.
00123 |
00124 |      Revision 1.4  2001/09/13 20:46:45  uzadow
00125 |      Removed 4096-byte limit for fillBuffer that was causing PLPNGEncoder
00126 |      to fail under Linux.
00127 |
00128 |
00129 \--------------------------------------------------------------------
00130 */

Generated on Sun Jun 6 13:42:22 2004 for paintlib by doxygen 1.3.2