Index: src/ch/BufferSizeDlg.cpp =================================================================== diff -u -raa6bff57279b9f9cfc276e9adab2763e2900878d -r6df9b4cff81dedf8c5571a98702b584b061eac09 --- src/ch/BufferSizeDlg.cpp (.../BufferSizeDlg.cpp) (revision aa6bff57279b9f9cfc276e9adab2763e2900878d) +++ src/ch/BufferSizeDlg.cpp (.../BufferSizeDlg.cpp) (revision 6df9b4cff81dedf8c5571a98702b584b061eac09) @@ -41,7 +41,7 @@ m_uiTwoDisksSize = 0; m_bOnlyDefaultCheck = FALSE; //}}AFX_DATA_INIT - m_iActiveIndex=BI_DEFAULT; + m_iActiveIndex = chcore::TBufferSizes::eBuffer_Default; } void CBufferSizeDlg::DoDataExchange(CDataExchange* pDX) @@ -97,37 +97,37 @@ m_ctlLANMulti.AddString(GetResManager().LoadString(IDS_MBYTE_STRING)); // fill edit controls and set multipliers - SetDefaultSize(m_bsSizes.m_uiDefaultSize); - SetOneDiskSize(m_bsSizes.m_uiOneDiskSize); - SetTwoDisksSize(m_bsSizes.m_uiTwoDisksSize); - SetCDSize(m_bsSizes.m_uiCDSize); - SetLANSize(m_bsSizes.m_uiLANSize); - m_bOnlyDefaultCheck=m_bsSizes.m_bOnlyDefault; + SetDefaultSize(m_bsSizes.GetDefaultSize()); + SetOneDiskSize(m_bsSizes.GetOneDiskSize()); + SetTwoDisksSize(m_bsSizes.GetTwoDisksSize()); + SetCDSize(m_bsSizes.GetCDSize()); + SetLANSize(m_bsSizes.GetLANSize()); + m_bOnlyDefaultCheck=m_bsSizes.IsOnlyDefault(); - EnableControls(!m_bsSizes.m_bOnlyDefault); + EnableControls(!m_bsSizes.IsOnlyDefault()); UpdateData(FALSE); // set focus to the requested control switch (m_iActiveIndex) { - case BI_DEFAULT: + case chcore::TBufferSizes::eBuffer_Default: GetDlgItem(IDC_DEFAULTSIZE_EDIT)->SetFocus(); static_cast(GetDlgItem(IDC_DEFAULTSIZE_EDIT))->SetSel(0, -1); break; - case BI_ONEDISK: + case chcore::TBufferSizes::eBuffer_OneDisk: GetDlgItem(IDC_ONEDISKSIZE_EDIT)->SetFocus(); static_cast(GetDlgItem(IDC_ONEDISKSIZE_EDIT))->SetSel(0, -1); break; - case BI_TWODISKS: + case chcore::TBufferSizes::eBuffer_TwoDisks: GetDlgItem(IDC_TWODISKSSIZE_EDIT)->SetFocus(); static_cast(GetDlgItem(IDC_TWODISKSSIZE_EDIT))->SetSel(0, -1); break; - case BI_CD: + case chcore::TBufferSizes::eBuffer_CD: GetDlgItem(IDC_CDROMSIZE_EDIT)->SetFocus(); static_cast(GetDlgItem(IDC_CDROMSIZE_EDIT))->SetSel(0, -1); break; - case BI_LAN: + case chcore::TBufferSizes::eBuffer_LAN: GetDlgItem(IDC_LANSIZE_EDIT)->SetFocus(); static_cast(GetDlgItem(IDC_LANSIZE_EDIT))->SetSel(0, -1); break; @@ -208,12 +208,12 @@ } // assign values - m_bsSizes.m_bOnlyDefault=m_bOnlyDefaultCheck != 0; - m_bsSizes.m_uiDefaultSize=m_uiDefaultSize*IndexToValue(m_ctlDefaultMulti.GetCurSel()); - m_bsSizes.m_uiOneDiskSize=m_uiOneDiskSize*IndexToValue(m_ctlOneDiskMulti.GetCurSel()); - m_bsSizes.m_uiTwoDisksSize=m_uiTwoDisksSize*IndexToValue(m_ctlTwoDisksMulti.GetCurSel()); - m_bsSizes.m_uiCDSize=m_uiCDROMSize*IndexToValue(m_ctlCDROMMulti.GetCurSel()); - m_bsSizes.m_uiLANSize=m_uiLANSize*IndexToValue(m_ctlLANMulti.GetCurSel()); + m_bsSizes.SetOnlyDefault(m_bOnlyDefaultCheck != 0); + m_bsSizes.SetDefaultSize(m_uiDefaultSize*IndexToValue(m_ctlDefaultMulti.GetCurSel())); + m_bsSizes.SetOneDiskSize(m_uiOneDiskSize*IndexToValue(m_ctlOneDiskMulti.GetCurSel())); + m_bsSizes.SetTwoDisksSize(m_uiTwoDisksSize*IndexToValue(m_ctlTwoDisksMulti.GetCurSel())); + m_bsSizes.SetCDSize(m_uiCDROMSize*IndexToValue(m_ctlCDROMMulti.GetCurSel())); + m_bsSizes.SetLANSize(m_uiLANSize*IndexToValue(m_ctlLANMulti.GetCurSel())); CLanguageDialog::OnOK(); } Index: src/ch/BufferSizeDlg.h =================================================================== diff -u -rd5c3edd0d167db9b5d47d04248820fda49499a5e -r6df9b4cff81dedf8c5571a98702b584b061eac09 --- src/ch/BufferSizeDlg.h (.../BufferSizeDlg.h) (revision d5c3edd0d167db9b5d47d04248820fda49499a5e) +++ src/ch/BufferSizeDlg.h (.../BufferSizeDlg.h) (revision 6df9b4cff81dedf8c5571a98702b584b061eac09) @@ -19,7 +19,7 @@ #ifndef __BUFFERSIZEDLG_H__ #define __BUFFERSIZEDLG_H__ -#include "DataBuffer.h" +#include "../libchcore/DataBuffer.h" ///////////////////////////////////////////////////////////////////////////// // CBufferSizeDlg dialog @@ -38,7 +38,7 @@ UINT IndexToValue(int iIndex); int m_iActiveIndex; - BUFFERSIZES m_bsSizes; + chcore::TBufferSizes m_bsSizes; // Dialog Data //{{AFX_DATA(CBufferSizeDlg) Index: src/ch/CustomCopyDlg.cpp =================================================================== diff -u -r4be0f47d68a1a161529dc55901659b9daec996e3 -r6df9b4cff81dedf8c5571a98702b584b061eac09 --- src/ch/CustomCopyDlg.cpp (.../CustomCopyDlg.cpp) (revision 4be0f47d68a1a161529dc55901659b9daec996e3) +++ src/ch/CustomCopyDlg.cpp (.../CustomCopyDlg.cpp) (revision 6df9b4cff81dedf8c5571a98702b584b061eac09) @@ -511,34 +511,34 @@ TCHAR szSize[64]; ictranslate::CFormat fmt; - BUFFERSIZES bsSizes; - bsSizes.m_bOnlyDefault = GetTaskPropValue(m_tTaskDefinition.GetConfiguration()); - bsSizes.m_uiDefaultSize = GetTaskPropValue(m_tTaskDefinition.GetConfiguration()); - bsSizes.m_uiOneDiskSize = GetTaskPropValue(m_tTaskDefinition.GetConfiguration()); - bsSizes.m_uiTwoDisksSize = GetTaskPropValue(m_tTaskDefinition.GetConfiguration()); - bsSizes.m_uiCDSize = GetTaskPropValue(m_tTaskDefinition.GetConfiguration()); - bsSizes.m_uiLANSize = GetTaskPropValue(m_tTaskDefinition.GetConfiguration()); + chcore::TBufferSizes bsSizes; + bsSizes.SetOnlyDefault(GetTaskPropValue(m_tTaskDefinition.GetConfiguration())); + bsSizes.SetDefaultSize(GetTaskPropValue(m_tTaskDefinition.GetConfiguration())); + bsSizes.SetOneDiskSize(GetTaskPropValue(m_tTaskDefinition.GetConfiguration())); + bsSizes.SetTwoDisksSize(GetTaskPropValue(m_tTaskDefinition.GetConfiguration())); + bsSizes.SetCDSize(GetTaskPropValue(m_tTaskDefinition.GetConfiguration())); + bsSizes.SetLANSize(GetTaskPropValue(m_tTaskDefinition.GetConfiguration())); fmt.SetFormat(GetResManager().LoadString(IDS_BSEDEFAULT_STRING)); - fmt.SetParam(_t("%size"), GetSizeString(bsSizes.m_uiDefaultSize, szSize, 64, true)); + fmt.SetParam(_t("%size"), GetSizeString(bsSizes.GetDefaultSize(), szSize, 64, true)); m_ctlBufferSizes.AddString(fmt); - if (!bsSizes.m_bOnlyDefault) + if (!bsSizes.IsOnlyDefault()) { fmt.SetFormat(GetResManager().LoadString(IDS_BSEONEDISK_STRING)); - fmt.SetParam(_t("%size"), GetSizeString(bsSizes.m_uiOneDiskSize, szSize, 64, true)); + fmt.SetParam(_t("%size"), GetSizeString(bsSizes.GetOneDiskSize(), szSize, 64, true)); m_ctlBufferSizes.AddString(fmt); fmt.SetFormat(GetResManager().LoadString(IDS_BSETWODISKS_STRING)); - fmt.SetParam(_t("%size"), GetSizeString(bsSizes.m_uiTwoDisksSize, szSize, 64, true)); + fmt.SetParam(_t("%size"), GetSizeString(bsSizes.GetTwoDisksSize(), szSize, 64, true)); m_ctlBufferSizes.AddString(fmt); fmt.SetFormat(GetResManager().LoadString(IDS_BSECD_STRING)); - fmt.SetParam(_t("%size"), GetSizeString(bsSizes.m_uiCDSize, szSize, 64, true)); + fmt.SetParam(_t("%size"), GetSizeString(bsSizes.GetCDSize(), szSize, 64, true)); m_ctlBufferSizes.AddString(fmt); fmt.SetFormat(GetResManager().LoadString(IDS_BSELAN_STRING)); - fmt.SetParam(_t("%size"), GetSizeString(bsSizes.m_uiLANSize, szSize, 64, true)); + fmt.SetParam(_t("%size"), GetSizeString(bsSizes.GetLANSize(), szSize, 64, true)); m_ctlBufferSizes.AddString(fmt); } } @@ -547,21 +547,21 @@ { CBufferSizeDlg dlg; - dlg.m_bsSizes.m_bOnlyDefault = GetTaskPropValue(m_tTaskDefinition.GetConfiguration()); - dlg.m_bsSizes.m_uiDefaultSize = GetTaskPropValue(m_tTaskDefinition.GetConfiguration()); - dlg.m_bsSizes.m_uiOneDiskSize = GetTaskPropValue(m_tTaskDefinition.GetConfiguration()); - dlg.m_bsSizes.m_uiTwoDisksSize = GetTaskPropValue(m_tTaskDefinition.GetConfiguration()); - dlg.m_bsSizes.m_uiCDSize = GetTaskPropValue(m_tTaskDefinition.GetConfiguration()); - dlg.m_bsSizes.m_uiLANSize = GetTaskPropValue(m_tTaskDefinition.GetConfiguration()); + dlg.m_bsSizes.SetOnlyDefault(GetTaskPropValue(m_tTaskDefinition.GetConfiguration())); + dlg.m_bsSizes.SetDefaultSize(GetTaskPropValue(m_tTaskDefinition.GetConfiguration())); + dlg.m_bsSizes.SetOneDiskSize(GetTaskPropValue(m_tTaskDefinition.GetConfiguration())); + dlg.m_bsSizes.SetTwoDisksSize(GetTaskPropValue(m_tTaskDefinition.GetConfiguration())); + dlg.m_bsSizes.SetCDSize(GetTaskPropValue(m_tTaskDefinition.GetConfiguration())); + dlg.m_bsSizes.SetLANSize(GetTaskPropValue(m_tTaskDefinition.GetConfiguration())); if(dlg.DoModal() == IDOK) { - SetTaskPropValue(m_tTaskDefinition.GetConfiguration(), dlg.m_bsSizes.m_bOnlyDefault); - SetTaskPropValue(m_tTaskDefinition.GetConfiguration(), dlg.m_bsSizes.m_uiDefaultSize); - SetTaskPropValue(m_tTaskDefinition.GetConfiguration(), dlg.m_bsSizes.m_uiOneDiskSize); - SetTaskPropValue(m_tTaskDefinition.GetConfiguration(), dlg.m_bsSizes.m_uiTwoDisksSize); - SetTaskPropValue(m_tTaskDefinition.GetConfiguration(), dlg.m_bsSizes.m_uiCDSize); - SetTaskPropValue(m_tTaskDefinition.GetConfiguration(), dlg.m_bsSizes.m_uiLANSize); + SetTaskPropValue(m_tTaskDefinition.GetConfiguration(), dlg.m_bsSizes.IsOnlyDefault()); + SetTaskPropValue(m_tTaskDefinition.GetConfiguration(), dlg.m_bsSizes.GetDefaultSize()); + SetTaskPropValue(m_tTaskDefinition.GetConfiguration(), dlg.m_bsSizes.GetOneDiskSize()); + SetTaskPropValue(m_tTaskDefinition.GetConfiguration(), dlg.m_bsSizes.GetTwoDisksSize()); + SetTaskPropValue(m_tTaskDefinition.GetConfiguration(), dlg.m_bsSizes.GetCDSize()); + SetTaskPropValue(m_tTaskDefinition.GetConfiguration(), dlg.m_bsSizes.GetLANSize()); SetBuffersizesString(); } @@ -874,22 +874,22 @@ { CBufferSizeDlg dlg; - dlg.m_bsSizes.m_bOnlyDefault = GetTaskPropValue(m_tTaskDefinition.GetConfiguration()); - dlg.m_bsSizes.m_uiDefaultSize = GetTaskPropValue(m_tTaskDefinition.GetConfiguration()); - dlg.m_bsSizes.m_uiOneDiskSize = GetTaskPropValue(m_tTaskDefinition.GetConfiguration()); - dlg.m_bsSizes.m_uiTwoDisksSize = GetTaskPropValue(m_tTaskDefinition.GetConfiguration()); - dlg.m_bsSizes.m_uiCDSize = GetTaskPropValue(m_tTaskDefinition.GetConfiguration()); - dlg.m_bsSizes.m_uiLANSize = GetTaskPropValue(m_tTaskDefinition.GetConfiguration()); + dlg.m_bsSizes.SetOnlyDefault(GetTaskPropValue(m_tTaskDefinition.GetConfiguration())); + dlg.m_bsSizes.SetDefaultSize(GetTaskPropValue(m_tTaskDefinition.GetConfiguration())); + dlg.m_bsSizes.SetOneDiskSize(GetTaskPropValue(m_tTaskDefinition.GetConfiguration())); + dlg.m_bsSizes.SetTwoDisksSize(GetTaskPropValue(m_tTaskDefinition.GetConfiguration())); + dlg.m_bsSizes.SetCDSize(GetTaskPropValue(m_tTaskDefinition.GetConfiguration())); + dlg.m_bsSizes.SetLANSize(GetTaskPropValue(m_tTaskDefinition.GetConfiguration())); dlg.m_iActiveIndex = iItem; if(dlg.DoModal() == IDOK) { - SetTaskPropValue(m_tTaskDefinition.GetConfiguration(), dlg.m_bsSizes.m_bOnlyDefault); - SetTaskPropValue(m_tTaskDefinition.GetConfiguration(), dlg.m_bsSizes.m_uiDefaultSize); - SetTaskPropValue(m_tTaskDefinition.GetConfiguration(), dlg.m_bsSizes.m_uiOneDiskSize); - SetTaskPropValue(m_tTaskDefinition.GetConfiguration(), dlg.m_bsSizes.m_uiTwoDisksSize); - SetTaskPropValue(m_tTaskDefinition.GetConfiguration(), dlg.m_bsSizes.m_uiCDSize); - SetTaskPropValue(m_tTaskDefinition.GetConfiguration(), dlg.m_bsSizes.m_uiLANSize); + SetTaskPropValue(m_tTaskDefinition.GetConfiguration(), dlg.m_bsSizes.IsOnlyDefault()); + SetTaskPropValue(m_tTaskDefinition.GetConfiguration(), dlg.m_bsSizes.GetDefaultSize()); + SetTaskPropValue(m_tTaskDefinition.GetConfiguration(), dlg.m_bsSizes.GetOneDiskSize()); + SetTaskPropValue(m_tTaskDefinition.GetConfiguration(), dlg.m_bsSizes.GetTwoDisksSize()); + SetTaskPropValue(m_tTaskDefinition.GetConfiguration(), dlg.m_bsSizes.GetCDSize()); + SetTaskPropValue(m_tTaskDefinition.GetConfiguration(), dlg.m_bsSizes.GetLANSize()); SetBuffersizesString(); } Index: src/ch/CustomCopyDlg.h =================================================================== diff -u -r2d7bee54f998ae8f5d4145a2cf3f4a589253016f -r6df9b4cff81dedf8c5571a98702b584b061eac09 --- src/ch/CustomCopyDlg.h (.../CustomCopyDlg.h) (revision 2d7bee54f998ae8f5d4145a2cf3f4a589253016f) +++ src/ch/CustomCopyDlg.h (.../CustomCopyDlg.h) (revision 6df9b4cff81dedf8c5571a98702b584b061eac09) @@ -19,7 +19,7 @@ #ifndef __CUSTOMCOPYDLG_H__ #define __CUSTOMCOPYDLG_H__ -#include "DataBuffer.h" +#include "../libchcore/DataBuffer.h" #include "FileFilter.h" #include "../libchcore/TTaskDefinition.h" Fisheye: Tag 6df9b4cff81dedf8c5571a98702b584b061eac09 refers to a dead (removed) revision in file `src/ch/DataBuffer.cpp'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 6df9b4cff81dedf8c5571a98702b584b061eac09 refers to a dead (removed) revision in file `src/ch/DataBuffer.h'. Fisheye: No comparison available. Pass `N' to diff? Index: src/ch/OptionsDlg.cpp =================================================================== diff -u -rb684bec49aaaea4b89ab2e599497f4085d8698a3 -r6df9b4cff81dedf8c5571a98702b584b061eac09 --- src/ch/OptionsDlg.cpp (.../OptionsDlg.cpp) (revision b684bec49aaaea4b89ab2e599497f4085d8698a3) +++ src/ch/OptionsDlg.cpp (.../OptionsDlg.cpp) (revision 6df9b4cff81dedf8c5571a98702b584b061eac09) @@ -134,12 +134,12 @@ COptionsDlg* pDlg=static_cast(lpParam); CBufferSizeDlg dlg; - dlg.m_bsSizes.m_bOnlyDefault=pDlg->GetBoolProp(iIndex-iParam-1); - dlg.m_bsSizes.m_uiDefaultSize=pDlg->GetUintProp(iIndex-iParam); - dlg.m_bsSizes.m_uiOneDiskSize=pDlg->GetUintProp(iIndex-iParam+1); - dlg.m_bsSizes.m_uiTwoDisksSize=pDlg->GetUintProp(iIndex-iParam+2); - dlg.m_bsSizes.m_uiCDSize=pDlg->GetUintProp(iIndex-iParam+3); - dlg.m_bsSizes.m_uiLANSize=pDlg->GetUintProp(iIndex-iParam+4); + dlg.m_bsSizes.SetOnlyDefault(pDlg->GetBoolProp(iIndex-iParam-1)); + dlg.m_bsSizes.SetDefaultSize(pDlg->GetUintProp(iIndex-iParam)); + dlg.m_bsSizes.SetOneDiskSize(pDlg->GetUintProp(iIndex-iParam+1)); + dlg.m_bsSizes.SetTwoDisksSize(pDlg->GetUintProp(iIndex-iParam+2)); + dlg.m_bsSizes.SetCDSize(pDlg->GetUintProp(iIndex-iParam+3)); + dlg.m_bsSizes.SetLANSize(pDlg->GetUintProp(iIndex-iParam+4)); dlg.m_iActiveIndex=iParam; // selected buffer for editing if (dlg.DoModal() == IDOK) @@ -148,17 +148,17 @@ TCHAR xx[32]; pItem = (PROPERTYITEM*)pList->GetAt(pList->FindIndex(iIndex-iParam-1)); - pItem->nPropertySelected=(dlg.m_bsSizes.m_bOnlyDefault ? 1 : 0); + pItem->nPropertySelected=(dlg.m_bsSizes.IsOnlyDefault() ? 1 : 0); pItem = (PROPERTYITEM*)pList->GetAt(pList->FindIndex(iIndex-iParam)); - pItem->csProperties.SetAt(0, _itot(dlg.m_bsSizes.m_uiDefaultSize, xx, 10)); + pItem->csProperties.SetAt(0, _itot(dlg.m_bsSizes.GetDefaultSize(), xx, 10)); pItem = (PROPERTYITEM*)pList->GetAt(pList->FindIndex(iIndex-iParam+1)); - pItem->csProperties.SetAt(0, _itot(dlg.m_bsSizes.m_uiOneDiskSize, xx, 10)); + pItem->csProperties.SetAt(0, _itot(dlg.m_bsSizes.GetOneDiskSize(), xx, 10)); pItem = (PROPERTYITEM*)pList->GetAt(pList->FindIndex(iIndex-iParam+2)); - pItem->csProperties.SetAt(0, _itot(dlg.m_bsSizes.m_uiTwoDisksSize, xx, 10)); + pItem->csProperties.SetAt(0, _itot(dlg.m_bsSizes.GetTwoDisksSize(), xx, 10)); pItem = (PROPERTYITEM*)pList->GetAt(pList->FindIndex(iIndex-iParam+3)); - pItem->csProperties.SetAt(0, _itot(dlg.m_bsSizes.m_uiCDSize, xx, 10)); + pItem->csProperties.SetAt(0, _itot(dlg.m_bsSizes.GetCDSize(), xx, 10)); pItem = (PROPERTYITEM*)pList->GetAt(pList->FindIndex(iIndex-iParam+4)); - pItem->csProperties.SetAt(0, _itot(dlg.m_bsSizes.m_uiLANSize, xx, 10)); + pItem->csProperties.SetAt(0, _itot(dlg.m_bsSizes.GetLANSize(), xx, 10)); } } Index: src/ch/StatusDlg.cpp =================================================================== diff -u -r0cd863a6e51b221c4f7bf6e7b83ddfc43a5d433f -r6df9b4cff81dedf8c5571a98702b584b061eac09 --- src/ch/StatusDlg.cpp (.../StatusDlg.cpp) (revision 0cd863a6e51b221c4f7bf6e7b83ddfc43a5d433f) +++ src/ch/StatusDlg.cpp (.../StatusDlg.cpp) (revision 6df9b4cff81dedf8c5571a98702b584b061eac09) @@ -813,19 +813,19 @@ TCHAR szData[1024]; switch(iIndex) { - case BI_DEFAULT: + case chcore::TBufferSizes::eBuffer_Default: GetResManager().LoadStringCopy(IDS_BSDEFAULT_STRING, szData, 256); break; - case BI_ONEDISK: + case chcore::TBufferSizes::eBuffer_OneDisk: GetResManager().LoadStringCopy(IDS_BSONEDISK_STRING, szData, 256); break; - case BI_TWODISKS: + case chcore::TBufferSizes::eBuffer_TwoDisks: GetResManager().LoadStringCopy(IDS_BSTWODISKS_STRING, szData, 256); break; - case BI_CD: + case chcore::TBufferSizes::eBuffer_CD: GetResManager().LoadStringCopy(IDS_BSCD_STRING, szData, 256); break; - case BI_LAN: + case chcore::TBufferSizes::eBuffer_LAN: GetResManager().LoadStringCopy(IDS_BSLAN_STRING, szData, 256); break; default: Index: src/ch/TLocalFilesystem.cpp =================================================================== diff -u -r8a7d1f41ad744b7dbe25e5cee2a99a2300eb2b5c -r6df9b4cff81dedf8c5571a98702b584b061eac09 --- src/ch/TLocalFilesystem.cpp (.../TLocalFilesystem.cpp) (revision 8a7d1f41ad744b7dbe25e5cee2a99a2300eb2b5c) +++ src/ch/TLocalFilesystem.cpp (.../TLocalFilesystem.cpp) (revision 6df9b4cff81dedf8c5571a98702b584b061eac09) @@ -25,7 +25,7 @@ #include #include "TAutoHandles.h" #include "FileInfo.h" -#include "DataBuffer.h" +#include "../libchcore/DataBuffer.h" #include UINT TLocalFilesystem::GetDriveData(const chcore::TSmartPath& spPath) @@ -423,15 +423,15 @@ return ::SetEndOfFile(m_hFile) != FALSE; } -bool TLocalFilesystemFile::ReadFile(CDataBuffer& rBuffer, DWORD dwToRead, DWORD& rdwBytesRead) +bool TLocalFilesystemFile::ReadFile(chcore::TDataBuffer& rBuffer, DWORD dwToRead, DWORD& rdwBytesRead) { if(!IsOpen()) return false; return ::ReadFile(m_hFile, rBuffer, dwToRead, &rdwBytesRead, NULL) != FALSE; } -bool TLocalFilesystemFile::WriteFile(CDataBuffer& rBuffer, DWORD dwToWrite, DWORD& rdwBytesWritten) +bool TLocalFilesystemFile::WriteFile(chcore::TDataBuffer& rBuffer, DWORD dwToWrite, DWORD& rdwBytesWritten) { if(!IsOpen()) return false; Index: src/ch/TLocalFilesystem.h =================================================================== diff -u -r4be0f47d68a1a161529dc55901659b9daec996e3 -r6df9b4cff81dedf8c5571a98702b584b061eac09 --- src/ch/TLocalFilesystem.h (.../TLocalFilesystem.h) (revision 4be0f47d68a1a161529dc55901659b9daec996e3) +++ src/ch/TLocalFilesystem.h (.../TLocalFilesystem.h) (revision 6df9b4cff81dedf8c5571a98702b584b061eac09) @@ -32,8 +32,12 @@ class TAutoFileHandle; class TLocalFilesystemFind; class TLocalFilesystemFile; -class CDataBuffer; +namespace chcore +{ + class TDataBuffer; +} + class TLocalFilesystem { public: @@ -110,8 +114,8 @@ bool SetFilePointer(long long llNewPos, DWORD dwMoveMethod); bool SetEndOfFile(); - bool ReadFile(CDataBuffer& rBuffer, DWORD dwToRead, DWORD& rdwBytesRead); - bool WriteFile(CDataBuffer& rBuffer, DWORD dwToWrite, DWORD& rdwBytesWritten); + bool ReadFile(chcore::TDataBuffer& rBuffer, DWORD dwToRead, DWORD& rdwBytesRead); + bool WriteFile(chcore::TDataBuffer& rBuffer, DWORD dwToWrite, DWORD& rdwBytesWritten); bool IsOpen() const { return m_hFile != INVALID_HANDLE_VALUE; } Index: src/ch/TSubTaskCopyMove.cpp =================================================================== diff -u -rd345f15636dc88c4c40fe310ac7777bd024e12d9 -r6df9b4cff81dedf8c5571a98702b584b061eac09 --- src/ch/TSubTaskCopyMove.cpp (.../TSubTaskCopyMove.cpp) (revision d345f15636dc88c4c40fe310ac7777bd024e12d9) +++ src/ch/TSubTaskCopyMove.cpp (.../TSubTaskCopyMove.cpp) (revision 6df9b4cff81dedf8c5571a98702b584b061eac09) @@ -37,7 +37,7 @@ CFileInfoPtr spSrcFile; // CFileInfo - src file chcore::TSmartPath pathDstFile; // dest path with filename - CDataBuffer dbBuffer; // buffer handling + chcore::TDataBuffer dbBuffer; // buffer handling bool bOnlyCreate; // flag from configuration - skips real copying - only create bool bProcessed; // has the element been processed ? (false if skipped) }; @@ -86,30 +86,30 @@ // remove changes in buffer sizes to avoid re-creation later rCfgTracker.RemoveModificationSet(TOptionsSet() % eTO_DefaultBufferSize % eTO_OneDiskBufferSize % eTO_TwoDisksBufferSize % eTO_CDBufferSize % eTO_LANBufferSize % eTO_UseOnlyDefaultBuffer); - BUFFERSIZES bs; - bs.m_bOnlyDefault = GetTaskPropValue(rTaskDefinition.GetConfiguration()); - bs.m_uiDefaultSize = GetTaskPropValue(rTaskDefinition.GetConfiguration()); - bs.m_uiOneDiskSize = GetTaskPropValue(rTaskDefinition.GetConfiguration()); - bs.m_uiTwoDisksSize = GetTaskPropValue(rTaskDefinition.GetConfiguration()); - bs.m_uiCDSize = GetTaskPropValue(rTaskDefinition.GetConfiguration()); - bs.m_uiLANSize = GetTaskPropValue(rTaskDefinition.GetConfiguration()); + chcore::TBufferSizes bs; + bs.SetOnlyDefault(GetTaskPropValue(rTaskDefinition.GetConfiguration())); + bs.SetDefaultSize(GetTaskPropValue(rTaskDefinition.GetConfiguration())); + bs.SetOneDiskSize(GetTaskPropValue(rTaskDefinition.GetConfiguration())); + bs.SetTwoDisksSize(GetTaskPropValue(rTaskDefinition.GetConfiguration())); + bs.SetCDSize(GetTaskPropValue(rTaskDefinition.GetConfiguration())); + bs.SetLANSize(GetTaskPropValue(rTaskDefinition.GetConfiguration())); - ccp.dbBuffer.Create(&bs); + ccp.dbBuffer.Create(bs); // helpers DWORD dwLastError = 0; // log - const BUFFERSIZES* pbs = ccp.dbBuffer.GetSizes(); + const chcore::TBufferSizes& rbs = ccp.dbBuffer.GetSizes(); ictranslate::CFormat fmt; fmt.SetFormat(_T("Processing files/folders (ProcessFiles):\r\n\tOnlyCreate: %create\r\n\tBufferSize: [Def:%defsize, One:%onesize, Two:%twosize, CD:%cdsize, LAN:%lansize]\r\n\tFiles/folders count: %filecount\r\n\tIgnore Folders: %ignorefolders\r\n\tDest path: %dstpath\r\n\tCurrent index (0-based): %currindex")); fmt.SetParam(_t("%create"), ccp.bOnlyCreate); - fmt.SetParam(_t("%defsize"), pbs->m_uiDefaultSize); - fmt.SetParam(_t("%onesize"), pbs->m_uiOneDiskSize); - fmt.SetParam(_t("%twosize"), pbs->m_uiTwoDisksSize); - fmt.SetParam(_t("%cdsize"), pbs->m_uiCDSize); - fmt.SetParam(_t("%lansize"), pbs->m_uiLANSize); + fmt.SetParam(_t("%defsize"), rbs.GetDefaultSize()); + fmt.SetParam(_t("%onesize"), rbs.GetOneDiskSize()); + fmt.SetParam(_t("%twosize"), rbs.GetTwoDisksSize()); + fmt.SetParam(_t("%cdsize"), rbs.GetCDSize()); + fmt.SetParam(_t("%lansize"), rbs.GetLANSize()); fmt.SetParam(_t("%filecount"), stSize); fmt.SetParam(_t("%ignorefolders"), bIgnoreFolders); fmt.SetParam(_t("%dstpath"), rTaskDefinition.GetDestinationPath().ToString()); @@ -288,20 +288,20 @@ switch(eRelation) { case TLocalFilesystem::eRelation_Network: - return BI_LAN; + return chcore::TBufferSizes::eBuffer_LAN; case TLocalFilesystem::eRelation_CDRom: - return BI_CD; + return chcore::TBufferSizes::eBuffer_CD; case TLocalFilesystem::eRelation_TwoPhysicalDisks: - return BI_TWODISKS; + return chcore::TBufferSizes::eBuffer_TwoDisks; case TLocalFilesystem::eRelation_SinglePhysicalDisk: - return BI_ONEDISK; + return chcore::TBufferSizes::eBuffer_OneDisk; //case eRelation_Other: default: - return BI_DEFAULT; + return chcore::TBufferSizes::eBuffer_Default; } } @@ -450,44 +450,44 @@ // recreate buffer if needed if(rCfgTracker.IsModified() && rCfgTracker.IsModified(TOptionsSet() % eTO_DefaultBufferSize % eTO_OneDiskBufferSize % eTO_TwoDisksBufferSize % eTO_CDBufferSize % eTO_LANBufferSize % eTO_UseOnlyDefaultBuffer, true)) { - BUFFERSIZES bs; - bs.m_bOnlyDefault = GetTaskPropValue(rTaskDefinition.GetConfiguration()); - bs.m_uiDefaultSize = GetTaskPropValue(rTaskDefinition.GetConfiguration()); - bs.m_uiOneDiskSize = GetTaskPropValue(rTaskDefinition.GetConfiguration()); - bs.m_uiTwoDisksSize = GetTaskPropValue(rTaskDefinition.GetConfiguration()); - bs.m_uiCDSize = GetTaskPropValue(rTaskDefinition.GetConfiguration()); - bs.m_uiLANSize = GetTaskPropValue(rTaskDefinition.GetConfiguration()); + chcore::TBufferSizes bs; + bs.SetOnlyDefault(GetTaskPropValue(rTaskDefinition.GetConfiguration())); + bs.SetDefaultSize(GetTaskPropValue(rTaskDefinition.GetConfiguration())); + bs.SetOneDiskSize(GetTaskPropValue(rTaskDefinition.GetConfiguration())); + bs.SetTwoDisksSize(GetTaskPropValue(rTaskDefinition.GetConfiguration())); + bs.SetCDSize(GetTaskPropValue(rTaskDefinition.GetConfiguration())); + bs.SetLANSize(GetTaskPropValue(rTaskDefinition.GetConfiguration())); // log - const BUFFERSIZES* pbs1 = pData->dbBuffer.GetSizes(); + const chcore::TBufferSizes& rbs1 = pData->dbBuffer.GetSizes(); fmt.SetFormat(_T("Changing buffer size from [Def:%defsize, One:%onesize, Two:%twosize, CD:%cdsize, LAN:%lansize] to [Def:%defsize2, One:%onesize2, Two:%twosize2, CD:%cdsize2, LAN:%lansize2] wile copying %srcfile -> %dstfile (CustomCopyFileFB)")); - fmt.SetParam(_t("%defsize"), pbs1->m_uiDefaultSize); - fmt.SetParam(_t("%onesize"), pbs1->m_uiOneDiskSize); - fmt.SetParam(_t("%twosize"), pbs1->m_uiTwoDisksSize); - fmt.SetParam(_t("%cdsize"), pbs1->m_uiCDSize); - fmt.SetParam(_t("%lansize"), pbs1->m_uiLANSize); - fmt.SetParam(_t("%defsize2"), bs.m_uiDefaultSize); - fmt.SetParam(_t("%onesize2"), bs.m_uiOneDiskSize); - fmt.SetParam(_t("%twosize2"), bs.m_uiTwoDisksSize); - fmt.SetParam(_t("%cdsize2"), bs.m_uiCDSize); - fmt.SetParam(_t("%lansize2"), bs.m_uiLANSize); + fmt.SetParam(_t("%defsize"), rbs1.GetDefaultSize()); + fmt.SetParam(_t("%onesize"), rbs1.GetOneDiskSize()); + fmt.SetParam(_t("%twosize"), rbs1.GetTwoDisksSize()); + fmt.SetParam(_t("%cdsize"), rbs1.GetCDSize()); + fmt.SetParam(_t("%lansize"), rbs1.GetLANSize()); + fmt.SetParam(_t("%defsize2"), bs.GetDefaultSize()); + fmt.SetParam(_t("%onesize2"), bs.GetOneDiskSize()); + fmt.SetParam(_t("%twosize2"), bs.GetTwoDisksSize()); + fmt.SetParam(_t("%cdsize2"), bs.GetCDSize()); + fmt.SetParam(_t("%lansize2"), bs.GetLANSize()); fmt.SetParam(_t("%srcfile"), pData->spSrcFile->GetFullFilePath().ToString()); fmt.SetParam(_t("%dstfile"), pData->pathDstFile.ToString()); rLog.logi(fmt); - pData->dbBuffer.Create(&bs); + pData->dbBuffer.Create(bs); } // establish count of data to read if(GetTaskPropValue(rTaskDefinition.GetConfiguration())) - iBufferIndex = BI_DEFAULT; + iBufferIndex = chcore::TBufferSizes::eBuffer_Default; else iBufferIndex = GetBufferIndex(pData->spSrcFile); rLocalStats.SetCurrentBufferIndex(iBufferIndex); - ulToRead = bNoBuffer ? ROUNDUP(pData->dbBuffer.GetSizes()->m_auiSizes[iBufferIndex], MAXSECTORSIZE) : pData->dbBuffer.GetSizes()->m_auiSizes[iBufferIndex]; + ulToRead = bNoBuffer ? ROUNDUP(pData->dbBuffer.GetSizes().GetSizeByType((chcore::TBufferSizes::EBufferType)iBufferIndex), MAXSECTORSIZE) : pData->dbBuffer.GetSizes().GetSizeByType((chcore::TBufferSizes::EBufferType)iBufferIndex); // read data from file to buffer eResult = ReadFileFB(fileSrc, pData->dbBuffer, ulToRead, ulRead, pData->spSrcFile->GetFullFilePath(), bSkip); @@ -958,7 +958,7 @@ return TSubTaskBase::eSubResult_Continue; } -TSubTaskBase::ESubOperationResult TSubTaskCopyMove::ReadFileFB(TLocalFilesystemFile& file, CDataBuffer& rBuffer, DWORD dwToRead, DWORD& rdwBytesRead, const chcore::TSmartPath& pathFile, bool& bSkip) +TSubTaskBase::ESubOperationResult TSubTaskCopyMove::ReadFileFB(TLocalFilesystemFile& file, chcore::TDataBuffer& rBuffer, DWORD dwToRead, DWORD& rdwBytesRead, const chcore::TSmartPath& pathFile, bool& bSkip) { chcore::IFeedbackHandler* piFeedbackHandler = GetContext().GetFeedbackHandler(); icpf::log_file& rLog = GetContext().GetLog(); @@ -1010,7 +1010,7 @@ return TSubTaskBase::eSubResult_Continue; } -TSubTaskBase::ESubOperationResult TSubTaskCopyMove::WriteFileFB(TLocalFilesystemFile& file, CDataBuffer& rBuffer, DWORD dwToWrite, DWORD& rdwBytesWritten, const chcore::TSmartPath& pathFile, bool& bSkip) +TSubTaskBase::ESubOperationResult TSubTaskCopyMove::WriteFileFB(TLocalFilesystemFile& file, chcore::TDataBuffer& rBuffer, DWORD dwToWrite, DWORD& rdwBytesWritten, const chcore::TSmartPath& pathFile, bool& bSkip) { chcore::IFeedbackHandler* piFeedbackHandler = GetContext().GetFeedbackHandler(); icpf::log_file& rLog = GetContext().GetLog(); Index: src/ch/TSubTaskCopyMove.h =================================================================== diff -u -r4be0f47d68a1a161529dc55901659b9daec996e3 -r6df9b4cff81dedf8c5571a98702b584b061eac09 --- src/ch/TSubTaskCopyMove.h (.../TSubTaskCopyMove.h) (revision 4be0f47d68a1a161529dc55901659b9daec996e3) +++ src/ch/TSubTaskCopyMove.h (.../TSubTaskCopyMove.h) (revision 6df9b4cff81dedf8c5571a98702b584b061eac09) @@ -25,8 +25,12 @@ #include "TSubTaskBase.h" +namespace chcore +{ + class TDataBuffer; +} + struct CUSTOM_COPY_PARAMS; -class CDataBuffer; class TLocalFilesystemFile; class TSubTaskCopyMove : public TSubTaskBase @@ -49,8 +53,8 @@ ESubOperationResult SetFilePointerFB(TLocalFilesystemFile& file, long long llDistance, const chcore::TSmartPath& pathFile, bool& bSkip); ESubOperationResult SetEndOfFileFB(TLocalFilesystemFile& file, const chcore::TSmartPath& pathFile, bool& bSkip); - ESubOperationResult ReadFileFB(TLocalFilesystemFile& file, CDataBuffer& rBuffer, DWORD dwToRead, DWORD& rdwBytesRead, const chcore::TSmartPath& pathFile, bool& bSkip); - ESubOperationResult WriteFileFB(TLocalFilesystemFile& file, CDataBuffer& rBuffer, DWORD dwToWrite, DWORD& rdwBytesWritten, const chcore::TSmartPath& pathFile, bool& bSkip); + ESubOperationResult ReadFileFB(TLocalFilesystemFile& file, chcore::TDataBuffer& rBuffer, DWORD dwToRead, DWORD& rdwBytesRead, const chcore::TSmartPath& pathFile, bool& bSkip); + ESubOperationResult WriteFileFB(TLocalFilesystemFile& file, chcore::TDataBuffer& rBuffer, DWORD dwToWrite, DWORD& rdwBytesWritten, const chcore::TSmartPath& pathFile, bool& bSkip); ESubOperationResult CreateDirectoryFB(const chcore::TSmartPath& pathDirectory); ESubOperationResult CheckForFreeSpaceFB(); Index: src/ch/ch.vc90.vcproj =================================================================== diff -u -rd345f15636dc88c4c40fe310ac7777bd024e12d9 -r6df9b4cff81dedf8c5571a98702b584b061eac09 --- src/ch/ch.vc90.vcproj (.../ch.vc90.vcproj) (revision d345f15636dc88c4c40fe310ac7777bd024e12d9) +++ src/ch/ch.vc90.vcproj (.../ch.vc90.vcproj) (revision 6df9b4cff81dedf8c5571a98702b584b061eac09) @@ -411,14 +411,6 @@ Name="Core" > - - - - Index: src/ch/task.cpp =================================================================== diff -u -r7a2963d79d6f2d590b6c30063b8fd8cd9d983924 -r6df9b4cff81dedf8c5571a98702b584b061eac09 --- src/ch/task.cpp (.../task.cpp) (revision 7a2963d79d6f2d590b6c30063b8fd8cd9d983924) +++ src/ch/task.cpp (.../task.cpp) (revision 6df9b4cff81dedf8c5571a98702b584b061eac09) @@ -95,26 +95,26 @@ return m_eCurrentState; } -void CTask::SetBufferSizes(const BUFFERSIZES& bsSizes) +void CTask::SetBufferSizes(const chcore::TBufferSizes& bsSizes) { m_tTaskDefinition.GetConfiguration().DelayNotifications(); - SetTaskPropValue(m_tTaskDefinition.GetConfiguration(), bsSizes.m_uiDefaultSize); - SetTaskPropValue(m_tTaskDefinition.GetConfiguration(), bsSizes.m_uiOneDiskSize); - SetTaskPropValue(m_tTaskDefinition.GetConfiguration(), bsSizes.m_uiTwoDisksSize); - SetTaskPropValue(m_tTaskDefinition.GetConfiguration(), bsSizes.m_uiCDSize); - SetTaskPropValue(m_tTaskDefinition.GetConfiguration(), bsSizes.m_uiLANSize); - SetTaskPropValue(m_tTaskDefinition.GetConfiguration(), bsSizes.m_bOnlyDefault); + SetTaskPropValue(m_tTaskDefinition.GetConfiguration(), bsSizes.GetDefaultSize()); + SetTaskPropValue(m_tTaskDefinition.GetConfiguration(), bsSizes.GetOneDiskSize()); + SetTaskPropValue(m_tTaskDefinition.GetConfiguration(), bsSizes.GetTwoDisksSize()); + SetTaskPropValue(m_tTaskDefinition.GetConfiguration(), bsSizes.GetCDSize()); + SetTaskPropValue(m_tTaskDefinition.GetConfiguration(), bsSizes.GetLANSize()); + SetTaskPropValue(m_tTaskDefinition.GetConfiguration(), bsSizes.IsOnlyDefault()); m_tTaskDefinition.GetConfiguration().ResumeNotifications(); } -void CTask::GetBufferSizes(BUFFERSIZES& bsSizes) +void CTask::GetBufferSizes(chcore::TBufferSizes& bsSizes) { - bsSizes.m_uiDefaultSize = GetTaskPropValue(m_tTaskDefinition.GetConfiguration()); - bsSizes.m_uiOneDiskSize = GetTaskPropValue(m_tTaskDefinition.GetConfiguration()); - bsSizes.m_uiTwoDisksSize = GetTaskPropValue(m_tTaskDefinition.GetConfiguration()); - bsSizes.m_uiCDSize = GetTaskPropValue(m_tTaskDefinition.GetConfiguration()); - bsSizes.m_uiLANSize = GetTaskPropValue(m_tTaskDefinition.GetConfiguration()); - bsSizes.m_bOnlyDefault = GetTaskPropValue(m_tTaskDefinition.GetConfiguration()); + bsSizes.SetDefaultSize(GetTaskPropValue(m_tTaskDefinition.GetConfiguration())); + bsSizes.SetOneDiskSize(GetTaskPropValue(m_tTaskDefinition.GetConfiguration())); + bsSizes.SetTwoDisksSize(GetTaskPropValue(m_tTaskDefinition.GetConfiguration())); + bsSizes.SetCDSize(GetTaskPropValue(m_tTaskDefinition.GetConfiguration())); + bsSizes.SetLANSize(GetTaskPropValue(m_tTaskDefinition.GetConfiguration())); + bsSizes.SetOnlyDefault(GetTaskPropValue(m_tTaskDefinition.GetConfiguration())); } int CTask::GetCurrentBufferIndex() @@ -412,23 +412,23 @@ if(m_files.GetSize() > 0) pData->m_iCurrentBufferIndex = m_localStats.GetCurrentBufferIndex(); else - pData->m_iCurrentBufferIndex = BI_DEFAULT; + pData->m_iCurrentBufferIndex = chcore::TBufferSizes::eBuffer_Default; switch(pData->m_iCurrentBufferIndex) { - case BI_DEFAULT: + case chcore::TBufferSizes::eBuffer_Default: pData->m_iCurrentBufferSize = GetTaskPropValue(m_tTaskDefinition.GetConfiguration()); break; - case BI_ONEDISK: + case chcore::TBufferSizes::eBuffer_OneDisk: pData->m_iCurrentBufferSize = GetTaskPropValue(m_tTaskDefinition.GetConfiguration()); break; - case BI_TWODISKS: + case chcore::TBufferSizes::eBuffer_TwoDisks: pData->m_iCurrentBufferSize = GetTaskPropValue(m_tTaskDefinition.GetConfiguration()); break; - case BI_CD: + case chcore::TBufferSizes::eBuffer_CD: pData->m_iCurrentBufferSize = GetTaskPropValue(m_tTaskDefinition.GetConfiguration()); break; - case BI_LAN: + case chcore::TBufferSizes::eBuffer_LAN: pData->m_iCurrentBufferSize = GetTaskPropValue(m_tTaskDefinition.GetConfiguration()); break; default: Index: src/ch/task.h =================================================================== diff -u -rd345f15636dc88c4c40fe310ac7777bd024e12d9 -r6df9b4cff81dedf8c5571a98702b584b061eac09 --- src/ch/task.h (.../task.h) (revision d345f15636dc88c4c40fe310ac7777bd024e12d9) +++ src/ch/task.h (.../task.h) (revision 6df9b4cff81dedf8c5571a98702b584b061eac09) @@ -22,7 +22,7 @@ #include "TAutoHandles.h" #include "../libchcore/TWorkerThreadController.h" #include "FileInfo.h" -#include "DataBuffer.h" +#include "../libchcore/DataBuffer.h" #include "../libchcore/FeedbackHandlerBase.h" #include "FileFilter.h" #include "../libchcore/TTaskDefinition.h" @@ -116,8 +116,8 @@ ETaskCurrentState GetTaskState() const; // m_nBufferSize - void SetBufferSizes(const BUFFERSIZES& bsSizes); - void GetBufferSizes(BUFFERSIZES& bsSizes); + void SetBufferSizes(const chcore::TBufferSizes& bsSizes); + void GetBufferSizes(chcore::TBufferSizes& bsSizes); int GetCurrentBufferIndex(); // thread Index: src/libchcore/DataBuffer.cpp =================================================================== diff -u --- src/libchcore/DataBuffer.cpp (revision 0) +++ src/libchcore/DataBuffer.cpp (revision 6df9b4cff81dedf8c5571a98702b584b061eac09) @@ -0,0 +1,202 @@ +/*************************************************************************** +* Copyright (C) 2001-2008 by J�zef Starosczyk * +* ixen@copyhandler.com * +* * +* This program is free software; you can redistribute it and/or modify * +* it under the terms of the GNU Library General Public License * +* (version 2) as published by the Free Software Foundation; * +* * +* This program is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU General Public License for more details. * +* * +* You should have received a copy of the GNU Library General Public * +* License along with this program; if not, write to the * +* Free Software Foundation, Inc., * +* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * +***************************************************************************/ +#include "stdafx.h" +#include "DataBuffer.h" +#include "TBinarySerializer.h" +#include "SerializationHelpers.h" + +BEGIN_CHCORE_NAMESPACE + +TBufferSizes::TBufferSizes() : + m_bOnlyDefault(false) +{ + memset(m_auiSizes, 0, sizeof(m_auiSizes)); +} + +void TBufferSizes::SerializeLoad(TReadBinarySerializer& rSerializer) +{ + using Serializers::Serialize; + + for(int iIndex = 0; iIndex < eBuffer_Last; ++iIndex) + { + Serialize(rSerializer, m_auiSizes[iIndex]); + } + Serialize(rSerializer, m_bOnlyDefault); +} + +void TBufferSizes::SerializeStore(TWriteBinarySerializer& rSerializer) +{ + using Serializers::Serialize; + + for(int iIndex = 0; iIndex < eBuffer_Last; ++iIndex) + { + Serialize(rSerializer, m_auiSizes[iIndex]); + } + + Serialize(rSerializer, m_bOnlyDefault); +} + +bool TBufferSizes::operator==(const TBufferSizes& bsSizes) const +{ + memcmp(m_auiSizes, bsSizes.m_auiSizes, sizeof(TBufferSizes)); + for(int iIndex = 0; iIndex < eBuffer_Last; ++iIndex) + { + if(m_auiSizes[iIndex] != bsSizes.m_auiSizes[iIndex]) + return false; + } + + return true; +} + +void TBufferSizes::Clear() +{ + memset(m_auiSizes, 0, sizeof(m_auiSizes)); + //m_bOnlyDefault = false; // disabled because in the earlier code it wasn't reset too +} + +UINT TBufferSizes::GetSizeByType(EBufferType eType) const +{ + if(eType < eBuffer_Default || eType > eBuffer_LAN) + THROW_CORE_EXCEPTION(eErr_BoundsExceeded); + + return m_auiSizes[eType]; +} + +void TBufferSizes::SetSizeByType(EBufferType eType, UINT uiSize) +{ + if(eType < eBuffer_Default || eType > eBuffer_LAN) + THROW_CORE_EXCEPTION(eErr_BoundsExceeded); + + m_auiSizes[eType] = uiSize; +} + +TDataBuffer::TDataBuffer() : + m_pBuffer(NULL), + m_uiRealSize(0) +{ +} + +TDataBuffer::~TDataBuffer() +{ + Delete(); +} + +const TBufferSizes& TDataBuffer::Create(const TBufferSizes& rbsSizes) +{ + // if trying to set 0-size buffer + TBufferSizes bsSizes = rbsSizes; // copy - not to mix in the def. param + + for(int iIndex = TBufferSizes::eBuffer_Default; iIndex < TBufferSizes::eBuffer_Last; ++iIndex) + { + TBufferSizes::EBufferType eType = (TBufferSizes::EBufferType)iIndex; + if(bsSizes.GetSizeByType(eType) == 0) + bsSizes.SetSizeByType(eType, DEFAULT_SIZE); + } + + // max value from the all + UINT uiLargest = 0; + if(bsSizes.IsOnlyDefault()) + uiLargest = bsSizes.GetDefaultSize(); + else + { + for(int iIndex = TBufferSizes::eBuffer_Default; iIndex < TBufferSizes::eBuffer_Last; ++iIndex) + { + TBufferSizes::EBufferType eType = (TBufferSizes::EBufferType)iIndex; + + if(uiLargest < bsSizes.GetSizeByType(eType)) + uiLargest = bsSizes.GetSizeByType(eType); + } + } + + // modify buffer size to the next 64k boundary + UINT uiRealSize = ROUNDTODS(uiLargest); + if(m_uiRealSize == uiRealSize) + { + // real buffersize hasn't changed + m_bsSizes = bsSizes; + + return m_bsSizes; + } + + // try to allocate buffer + LPVOID pBuffer = VirtualAlloc(NULL, uiRealSize, MEM_COMMIT, PAGE_READWRITE); + if(pBuffer == NULL) + { + if(m_pBuffer == NULL) + { + // try safe buffesize + pBuffer = VirtualAlloc(NULL, DEFAULT_SIZE, MEM_COMMIT, PAGE_READWRITE); + if(pBuffer == NULL) + return m_bsSizes; // do not change anything + + // delete old buffer + Delete(); + + // store data + m_pBuffer = static_cast(pBuffer); + m_uiRealSize = DEFAULT_SIZE; + m_bsSizes.SetOnlyDefault(bsSizes.IsOnlyDefault()); + m_bsSizes.SetDefaultSize(DEFAULT_SIZE); + m_bsSizes.SetOneDiskSize(DEFAULT_SIZE); + m_bsSizes.SetTwoDisksSize(DEFAULT_SIZE); + m_bsSizes.SetCDSize(DEFAULT_SIZE); + m_bsSizes.SetLANSize(DEFAULT_SIZE); + + return m_bsSizes; + } + else + { + // no new buffer could be created - leave the old one + return m_bsSizes; + } + } + else + { + // succeeded + Delete(); // get rid of old buffer + + // store data + m_pBuffer = static_cast(pBuffer); + m_uiRealSize = uiRealSize; + m_bsSizes = bsSizes; + + return m_bsSizes; + } +} + +void TDataBuffer::Delete() +{ + if(m_pBuffer != NULL) + { + VirtualFree(static_cast(m_pBuffer), 0, MEM_RELEASE); + m_pBuffer = NULL; + m_uiRealSize = 0; + m_bsSizes.Clear(); + } +} + +void TDataBuffer::CutDataFromBuffer(UINT uiCount) +{ + if(uiCount >= m_uiRealSize || !m_pBuffer) + return; // nothing to do + + memmove(m_pBuffer, m_pBuffer + uiCount, m_uiRealSize - uiCount); +} + +END_CHCORE_NAMESPACE Index: src/libchcore/DataBuffer.h =================================================================== diff -u --- src/libchcore/DataBuffer.h (revision 0) +++ src/libchcore/DataBuffer.h (revision 6df9b4cff81dedf8c5571a98702b584b061eac09) @@ -0,0 +1,119 @@ +/*************************************************************************** +* Copyright (C) 2001-2008 by J�zef Starosczyk * +* ixen@copyhandler.com * +* * +* This program is free software; you can redistribute it and/or modify * +* it under the terms of the GNU Library General Public License * +* (version 2) as published by the Free Software Foundation; * +* * +* This program is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU General Public License for more details. * +* * +* You should have received a copy of the GNU Library General Public * +* License along with this program; if not, write to the * +* Free Software Foundation, Inc., * +* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * +***************************************************************************/ +#ifndef __DATABUFFER_H__ +#define __DATABUFFER_H__ + +#include "libchcore.h" + +BEGIN_CHCORE_NAMESPACE + +#define DEFAULT_SIZE 65536 + +#define ROUNDTODS(number)\ + ((number + DEFAULT_SIZE - 1) & ~(DEFAULT_SIZE-1)) + +#define ROUNDUP(number, to)\ + ((number + to - 1) & ~(to-1)) + +#define ROUNDDOWN(number, to)\ + (number & ~(to-1)) + +class TReadBinarySerializer; +class TWriteBinarySerializer; + +//#pragma warning (disable: 4201) +class LIBCHCORE_API TBufferSizes +{ +public: + enum EBufferType + { + eBuffer_Default = 0, + eBuffer_OneDisk = 1, + eBuffer_TwoDisks = 2, + eBuffer_CD = 3, + eBuffer_LAN = 4, + + // do not remove this marker + eBuffer_Last + }; + +public: + TBufferSizes(); + + void SerializeLoad(TReadBinarySerializer& rSerializer); + void SerializeStore(TWriteBinarySerializer& rSerializer); + + bool operator==(const TBufferSizes& bsSizes) const; + + void Clear(); + + bool IsOnlyDefault() const { return m_bOnlyDefault; } + UINT GetDefaultSize() const { return m_auiSizes[eBuffer_Default]; } + UINT GetOneDiskSize() const { return m_auiSizes[eBuffer_OneDisk]; } + UINT GetTwoDisksSize() const { return m_auiSizes[eBuffer_TwoDisks]; } + UINT GetCDSize() const { return m_auiSizes[eBuffer_CD]; } + UINT GetLANSize() const { return m_auiSizes[eBuffer_LAN]; } + UINT GetSizeByType(EBufferType eType) const; + + void SetOnlyDefault(bool bOnlyDefault) { m_bOnlyDefault = bOnlyDefault; } + void SetDefaultSize(UINT uiSize) { m_auiSizes[eBuffer_Default] = uiSize; } + void SetOneDiskSize(UINT uiSize) { m_auiSizes[eBuffer_OneDisk] = uiSize; } + void SetTwoDisksSize(UINT uiSize) { m_auiSizes[eBuffer_TwoDisks] = uiSize; } + void SetCDSize(UINT uiSize) { m_auiSizes[eBuffer_CD] = uiSize; } + void SetLANSize(UINT uiSize) { m_auiSizes[eBuffer_LAN] = uiSize; } + void SetSizeByType(EBufferType eType, UINT uiSize); + +private: + UINT m_auiSizes[eBuffer_Last]; + bool m_bOnlyDefault; +}; +//#pragma warning (default: 4201) + +class LIBCHCORE_API TDataBuffer +{ +public: + TDataBuffer(); + ~TDataBuffer(); + + const TBufferSizes& Create(const TBufferSizes& rbsSizes); // (re)allocates the buffer; if there's an error - restores previous buffer size + void Delete(); // deletes buffer + + UINT GetRealSize() { return m_uiRealSize; } + UINT GetDefaultSize() { return m_bsSizes.GetDefaultSize(); } + UINT GetOneDiskSize() { return m_bsSizes.GetOneDiskSize(); } + UINT GetTwoDisksSize() { return m_bsSizes.GetTwoDisksSize(); } + UINT GetCDSize() { return m_bsSizes.GetCDSize(); } + UINT GetLANSize() { return m_bsSizes.GetLANSize(); } + const TBufferSizes& GetSizes() { return m_bsSizes; } + + // shifts data from buffer from position uiCount to 0 (effectively cuts uiCount bytes of data at the beginning of buffer) + void CutDataFromBuffer(UINT uiCount); + + // operators + operator unsigned char*() { return m_pBuffer; } + +protected: + unsigned char *m_pBuffer; // buffer address + UINT m_uiRealSize; // real buffer size + TBufferSizes m_bsSizes; +}; + +END_CHCORE_NAMESPACE + +#endif \ No newline at end of file Index: src/libchcore/libchcore.vc90.vcproj =================================================================== diff -u -rd345f15636dc88c4c40fe310ac7777bd024e12d9 -r6df9b4cff81dedf8c5571a98702b584b061eac09 --- src/libchcore/libchcore.vc90.vcproj (.../libchcore.vc90.vcproj) (revision d345f15636dc88c4c40fe310ac7777bd024e12d9) +++ src/libchcore/libchcore.vc90.vcproj (.../libchcore.vc90.vcproj) (revision 6df9b4cff81dedf8c5571a98702b584b061eac09) @@ -340,6 +340,14 @@ Name="Core" > + + + +