00001
00002
00003
00004
00005
00006
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
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
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;
00071 HANDLE m_hm;
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
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130