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

plfilesrc.h

00001 /*
00002 /--------------------------------------------------------------------
00003 |
00004 |      $Id: plfilesrc_8h-source.html,v 1.4 2004/09/15 15:26:29 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 
00021 #ifdef _WINDOWS
00022   typedef void *HANDLE;
00023 #endif
00024 
00025 #include <stdio.h>
00026 
00027 class PLIProgressNotification;
00028 
00029 //! This is a class which takes a file as a source of picture data.
00030 class PLFileSource : public PLDataSource
00031 {
00032 
00033 public:
00034   //!
00035   PLFileSource
00036     ( PLIProgressNotification * pNotification = NULL
00037     );
00038 
00039   //!
00040   virtual ~PLFileSource
00041     ();
00042 
00043   //!
00044   virtual int Open
00045     ( const char * pszFName
00046     );
00047 #ifdef _WINDOWS
00048   virtual int OpenW
00049     ( const wchar_t * pszwFName
00050     );
00051 #endif
00052 
00053   //!
00054   virtual void Close
00055     ();
00056 
00057   virtual PLBYTE * ReadNBytes
00058     ( int n
00059     );
00060 
00061   //! Read but don't advance file pointer.
00062   virtual PLBYTE * GetBufferPtr
00063     ( int MinBytesInBuffer
00064     );
00065 
00066   virtual PLBYTE * ReadEverything
00067     ();
00068 
00069   //!
00070   virtual void Seek
00071     ( int n
00072     );
00073 
00074 private:
00075   void isBufferOk (int NumBytes);
00076 #ifdef _WINDOWS
00077   int mapFileHandle();
00078   int getLastPLError();
00079   
00080   HANDLE m_hf;    // File handle.
00081   HANDLE m_hm;    // Handle to file-mapping object.
00082 #else
00083   #ifdef HAVE_MMAP
00084   
00085   #else  
00086   bool bytesAvailable
00087     ( int n
00088     );
00089 
00090   void fillBuffer
00091     ( int n = 4096
00092     );
00093 
00094   FILE * m_pFile;
00095   PLBYTE * m_pBuffer;
00096 
00097   PLBYTE * m_pReadPos;
00098   int m_BytesReadFromFile;
00099   #endif
00100 #endif
00101   PLBYTE * m_pStartData;
00102   PLBYTE * m_pCurPos;
00103 };
00104 
00105 #endif
00106 /*
00107 /--------------------------------------------------------------------
00108 |
00109 |      $Log: plfilesrc_8h-source.html,v $
00109 |      Revision 1.4  2004/09/15 15:26:29  uzadow
00109 |      Linux compatibility changes, doc update.
00109 |
00110 |      Revision 1.10  2004/09/11 12:41:35  uzadow
00111 |      removed plstdpch.h
00112 |
00113 |      Revision 1.9  2004/08/20 14:39:37  uzadow
00114 |      Added rle format to sgi decoder. Doesn't work yet, though.
00115 |
00116 |      Revision 1.8  2003/11/22 13:11:34  uzadow
00117 |      Added memory-mapped file support for linux
00118 |
00119 |      Revision 1.7  2003/08/03 12:36:56  uzadow
00120 |      Added unicode support; fixed some header includes.
00121 |
00122 |      Revision 1.6  2003/08/03 12:03:20  uzadow
00123 |      Added unicode support; fixed some header includes.
00124 |
00125 |      Revision 1.5  2003/04/20 22:20:49  uzadow
00126 |      Added check for errors reading memory-mapped files.
00127 |
00128 |      Revision 1.4  2002/03/31 13:36:41  uzadow
00129 |      Updated copyright.
00130 |
00131 |      Revision 1.3  2001/10/06 22:37:08  uzadow
00132 |      Linux compatibility.
00133 |
00134 |      Revision 1.2  2001/09/16 20:57:17  uzadow
00135 |      Linux version name prefix changes
00136 |
00137 |      Revision 1.1  2001/09/16 19:03:22  uzadow
00138 |      Added global name prefix PL, changed most filenames.
00139 |
00140 |      Revision 1.4  2001/09/13 20:46:45  uzadow
00141 |      Removed 4096-byte limit for fillBuffer that was causing PLPNGEncoder
00142 |      to fail under Linux.
00143 |
00144 |
00145 \--------------------------------------------------------------------
00146 */

Generated on Mon Sep 13 16:16:40 2004 for paintlib by doxygen 1.3.2