00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #include "plstdpch.h"
00016
00017 #include "pldatasrc.h"
00018 #include "plprognot.h"
00019
00020
00021 PLDataSource::PLDataSource
00022 (
00023 PLIProgressNotification * pNotification
00024 )
00025 : PLObject(),
00026 m_pszName(NULL),
00027 m_FileSize(0),
00028 m_BytesRead(0),
00029 m_bSrcLSBFirst(true),
00030
00031 m_pNotification(pNotification)
00032
00033 {
00034 }
00035
00036
00037 PLDataSource::~PLDataSource
00038 ()
00039 {
00040 }
00041
00042
00043 void PLDataSource::Open
00044 ( const char * pszName,
00045 int FileSize
00046 )
00047 {
00048
00049 PLASSERT (!m_FileSize);
00050
00051 m_pszName = new char [strlen (pszName)+1];
00052 strcpy (m_pszName, pszName);
00053 m_FileSize = FileSize;
00054 m_BytesRead = 0;
00055 }
00056
00057
00058 void PLDataSource::Close
00059 ()
00060 {
00061 if (m_pNotification)
00062
00063 m_pNotification->OnProgress( 1);
00064 delete [] m_pszName;
00065 m_pszName = NULL;
00066 }
00067
00068
00069 char * PLDataSource::GetName
00070 ()
00071 {
00072 return m_pszName;
00073 }
00074
00075 PLBYTE * PLDataSource::ReadNBytes
00076 ( int n
00077 )
00078 {
00079 int OldBytesRead = m_BytesRead;
00080 m_BytesRead += n;
00081 if (m_BytesRead/1024 > OldBytesRead/1024 && m_pNotification)
00082 m_pNotification->OnProgress (double(m_BytesRead)/m_FileSize);
00083 CheckEOF();
00084 return NULL;
00085 }
00086
00087
00088
00089 void PLDataSource::OProgressNotification
00090 ( double part
00091 )
00092 {
00093 if( m_pNotification)
00094 m_pNotification->OnProgress( part);
00095 }
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