Index: src/ch/ClipboardMonitor.cpp =================================================================== diff -u -N -r55ef81d592f615cf6fdff83fab4850b40efaa15e -r5057e08b0cc064972abeb94a488e5f12d9db14a0 --- src/ch/ClipboardMonitor.cpp (.../ClipboardMonitor.cpp) (revision 55ef81d592f615cf6fdff83fab4850b40efaa15e) +++ src/ch/ClipboardMonitor.cpp (.../ClipboardMonitor.cpp) (revision 5057e08b0cc064972abeb94a488e5f12d9db14a0) @@ -97,7 +97,7 @@ TCHAR path[_MAX_PATH]; // UINT i; // counter CTask *pTask; // ptr to a task - CClipboardEntry* pEntry=NULL; + CClipboardEntryPtr spEntry; // register clipboard format UINT nFormat=RegisterClipboardFormat(_T("Preferred DropEffect")); @@ -121,9 +121,9 @@ for (UINT i=0;i(handle), i, path, _MAX_PATH); - pEntry=new CClipboardEntry; - pEntry->SetPath(path); - pTask->AddClipboardData(pEntry); + spEntry.reset(new CClipboardEntry); + spEntry->SetPath(path); + pTask->AddClipboardData(spEntry); } if (IsClipboardFormatAvailable(nFormat)) @@ -194,13 +194,15 @@ dlg.m_bdData.strText=GetResManager().LoadString(IDS_MAINBROWSETEXT_STRING); // set count of data to display - int iClipboardSize=pTask->GetClipboardDataSize(); - int iEntries=(iClipboardSize > 3) ? 2 : iClipboardSize; - for (int i=0;iGetClipboardData(i)->GetPath()+_T("\n"); + size_t stClipboardSize = pTask->GetClipboardDataSize(); + size_t stEntries = (stClipboardSize > 3) ? 2 : stClipboardSize; + for(size_t i = 0; i < stEntries; i++) + { + dlg.m_bdData.strText += pTask->GetClipboardData(i)->GetPath() + _T("\n"); + } // add ... - if (iEntries < iClipboardSize) + if (stEntries < stClipboardSize) dlg.m_bdData.strText+=_T("..."); // show window Index: src/ch/CustomCopyDlg.cpp =================================================================== diff -u -N -r25aab92a9d195154393782ca83cbf5bc41ab9277 -r5057e08b0cc064972abeb94a488e5f12d9db14a0 --- src/ch/CustomCopyDlg.cpp (.../CustomCopyDlg.cpp) (revision 25aab92a9d195154393782ca83cbf5bc41ab9277) +++ src/ch/CustomCopyDlg.cpp (.../CustomCopyDlg.cpp) (revision 5057e08b0cc064972abeb94a488e5f12d9db14a0) @@ -941,7 +941,6 @@ CFileDialog dlg(TRUE, NULL, NULL, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, GetResManager().LoadString(IDS_FLTALLFILTER_STRING)); if (dlg.DoModal() == IDOK) { - const int iMaxLineLength = 4096; UINT uiCount=0; try { @@ -962,7 +961,7 @@ ulSize = file.read(spBuffer.get(), (ulong_t)llSize); file.close(); } - catch(icpf::exception& /*e*/) + catch(...) { AfxMessageBox(GetResManager().LoadString(IDS_IMPORTERROR_STRING)); return; Index: src/ch/DataBuffer.cpp =================================================================== diff -u -N -r2b67cda63fcaa69c7838641d33198e10f37af9e1 -r5057e08b0cc064972abeb94a488e5f12d9db14a0 --- src/ch/DataBuffer.cpp (.../DataBuffer.cpp) (revision 2b67cda63fcaa69c7838641d33198e10f37af9e1) +++ src/ch/DataBuffer.cpp (.../DataBuffer.cpp) (revision 5057e08b0cc064972abeb94a488e5f12d9db14a0) @@ -32,30 +32,6 @@ && m_uiLANSize == bsSizes.m_uiLANSize); } -void BUFFERSIZES::Serialize(icpf::archive& ar) -{ - if (ar.is_storing()) - { - ar<(m_bOnlyDefault); - } - else - { - ar>>m_uiDefaultSize; - ar>>m_uiOneDiskSize; - ar>>m_uiTwoDisksSize; - ar>>m_uiCDSize; - ar>>m_uiLANSize; - unsigned char ucTemp; - ar>>ucTemp; - m_bOnlyDefault=(ucTemp != 0); - } -} - const BUFFERSIZES* CDataBuffer::Create(const BUFFERSIZES* pbsSizes) { // if trying to set 0-size buffer Index: src/ch/DataBuffer.h =================================================================== diff -u -N -rd5c3edd0d167db9b5d47d04248820fda49499a5e -r5057e08b0cc064972abeb94a488e5f12d9db14a0 --- src/ch/DataBuffer.h (.../DataBuffer.h) (revision d5c3edd0d167db9b5d47d04248820fda49499a5e) +++ src/ch/DataBuffer.h (.../DataBuffer.h) (revision 5057e08b0cc064972abeb94a488e5f12d9db14a0) @@ -19,8 +19,6 @@ #ifndef __DATABUFFER_H__ #define __DATABUFFER_H__ -#include "../libicpf/file.h" - #define DEFAULT_SIZE 65536 #define ROUNDTODS(number)\ @@ -41,8 +39,19 @@ #pragma warning (disable: 4201) struct BUFFERSIZES { - void Serialize(icpf::archive& ar); + template + void serialize(Archive& ar, unsigned int /*uiVersion*/) + { + ar & m_uiDefaultSize; + ar & m_uiOneDiskSize; + ar & m_uiTwoDisksSize; + ar & m_uiCDSize; + ar & m_uiLANSize; + ar & m_bOnlyDefault; + } + bool operator==(const BUFFERSIZES& bsSizes) const; + union { struct @@ -78,6 +87,7 @@ // operators operator unsigned char*() { return m_pBuffer; }; + protected: unsigned char *m_pBuffer; // buffer address UINT m_uiRealSize; // real buffer size Index: src/ch/DestPath.cpp =================================================================== diff -u -N -rd5c3edd0d167db9b5d47d04248820fda49499a5e -r5057e08b0cc064972abeb94a488e5f12d9db14a0 --- src/ch/DestPath.cpp (.../DestPath.cpp) (revision d5c3edd0d167db9b5d47d04248820fda49499a5e) +++ src/ch/DestPath.cpp (.../DestPath.cpp) (revision 5057e08b0cc064972abeb94a488e5f12d9db14a0) @@ -18,7 +18,6 @@ ***************************************************************************/ #include "stdafx.h" #include "DestPath.h" -//#include "../libicpf/file.h" #ifdef _DEBUG #define new DEBUG_NEW @@ -74,19 +73,3 @@ GetDriveData(m_strPath, &m_iDriveNumber, &m_uiDriveType); } - -void CDestPath::Serialize(icpf::archive& ar) -{ - if (ar.is_storing()) - { - ar<>m_strPath; - ar>>m_iDriveNumber; - ar>>m_uiDriveType; - } -} Index: src/ch/DestPath.h =================================================================== diff -u -N -rd5c3edd0d167db9b5d47d04248820fda49499a5e -r5057e08b0cc064972abeb94a488e5f12d9db14a0 --- src/ch/DestPath.h (.../DestPath.h) (revision d5c3edd0d167db9b5d47d04248820fda49499a5e) +++ src/ch/DestPath.h (.../DestPath.h) (revision 5057e08b0cc064972abeb94a488e5f12d9db14a0) @@ -19,8 +19,6 @@ #ifndef __DESTPATH_H__ #define __DESTPATH_H__ -#include "../libicpf/file.h" - class CDestPath { public: @@ -31,7 +29,13 @@ int GetDriveNumber() const { return m_iDriveNumber; }; UINT GetDriveType() const { return m_uiDriveType; }; - void Serialize(icpf::archive& ar); + template + void serialize(Archive& ar, unsigned int /*uiVersion*/) + { + ar & m_strPath; + ar & m_iDriveNumber; + ar & m_uiDriveType; + } protected: CString m_strPath; // always with ending '\\' Index: src/ch/FeedbackReplaceDlg.cpp =================================================================== diff -u -N -r17059054c69cd5726f4c7d35357f3b9556471783 -r5057e08b0cc064972abeb94a488e5f12d9db14a0 --- src/ch/FeedbackReplaceDlg.cpp (.../FeedbackReplaceDlg.cpp) (revision 17059054c69cd5726f4c7d35357f3b9556471783) +++ src/ch/FeedbackReplaceDlg.cpp (.../FeedbackReplaceDlg.cpp) (revision 5057e08b0cc064972abeb94a488e5f12d9db14a0) @@ -98,14 +98,17 @@ ictranslate::CFormat fmt(strTemplate); fmt.SetParam(_T("%filename"), m_pfiSrcFile->GetFullFilePath()); fmt.SetParam(_T("%size"), m_pfiSrcFile->GetLength64()); - fmt.SetParam(_T("%datemod"), m_pfiSrcFile->GetLastWriteTime().Format(LOCALE_NOUSEROVERRIDE, LANG_USER_DEFAULT)); + COleDateTime dtTemp = m_pfiSrcFile->GetLastWriteTime(); + fmt.SetParam(_T("%datemod"), dtTemp.Format(LOCALE_NOUSEROVERRIDE, LANG_USER_DEFAULT)); + m_ctlSrcInfo.SetWindowText(fmt); fmt.SetFormat(strTemplate); fmt.SetParam(_T("%filename"), m_pfiDstFile->GetFullFilePath()); fmt.SetParam(_T("%size"), m_pfiDstFile->GetLength64()); - fmt.SetParam(_T("%datemod"), m_pfiDstFile->GetLastWriteTime().Format(LOCALE_NOUSEROVERRIDE, LANG_USER_DEFAULT)); + dtTemp = m_pfiDstFile->GetLastWriteTime(); + fmt.SetParam(_T("%datemod"), dtTemp.Format(LOCALE_NOUSEROVERRIDE, LANG_USER_DEFAULT)); m_ctlDstInfo.SetWindowText(fmt); } Index: src/ch/FileFilter.cpp =================================================================== diff -u -N -rd5c3edd0d167db9b5d47d04248820fda49499a5e -r5057e08b0cc064972abeb94a488e5f12d9db14a0 --- src/ch/FileFilter.cpp (.../FileFilter.cpp) (revision d5c3edd0d167db9b5d47d04248820fda49499a5e) +++ src/ch/FileFilter.cpp (.../FileFilter.cpp) (revision 5057e08b0cc064972abeb94a488e5f12d9db14a0) @@ -31,10 +31,10 @@ { // files mask m_bUseMask=false; - m_astrMask.RemoveAll(); + m_astrMask.clear(); m_bUseExcludeMask=false; - m_astrExcludeMask.RemoveAll(); + m_astrExcludeMask.clear(); // size filtering m_bUseSize=false; @@ -78,10 +78,10 @@ { // files mask m_bUseMask=rFilter.m_bUseMask; - m_astrMask.Copy(rFilter.m_astrMask); + m_astrMask = rFilter.m_astrMask; m_bUseExcludeMask=rFilter.m_bUseExcludeMask; - m_astrExcludeMask.Copy(rFilter.m_astrExcludeMask); + m_astrExcludeMask = rFilter.m_astrExcludeMask; // size filtering m_bUseSize=rFilter.m_bUseSize; @@ -118,132 +118,22 @@ return *this; } -void CFileFilter::Serialize(icpf::archive& ar) +CString& CFileFilter::GetCombinedMask(CString& strMask) const { - ULARGE_INTEGER li; - if (ar.is_storing()) + strMask.Empty(); + if(m_astrMask.size() > 0) { - // store - // files mask - ar<(m_bUseMask); - ar<(m_bUseExcludeMask); - // ar<(m_bUseSize); - ar<(m_bUseSize2); - ar<(m_bUseDate); - ar<(m_bDate1); - ar<(m_bTime1); - ar<(m_bUseDate2); - ar<(m_bDate2); - ar<(m_bTime2); - ar<(m_bUseAttributes); - ar<>tmp; - m_bUseMask=(tmp != 0); - ar>>m_astrMask; - - ar>>tmp; - m_bUseExcludeMask=(tmp != 0); - ar>>m_astrExcludeMask; - - // size - ar>>tmp; - m_bUseSize=(tmp != 0); - ar>>m_iSizeType1; - ar>>li.LowPart; - ar>>li.HighPart; - m_ullSize1=li.QuadPart; - ar>>tmp; - m_bUseSize2=(tmp != 0); - ar>>m_iSizeType2; - ar>>li.LowPart; - ar>>li.HighPart; - m_ullSize2=li.QuadPart; - - // date - ar>>tmp; - m_bUseDate=(tmp != 0); - ar>>m_iDateType; - ar>>m_iDateType1; - ar>>tmp; - m_bDate1=(tmp != 0); - ar>>m_tDate1; - ar>>tmp; - m_bTime1=(tmp != 0); - ar>>m_tTime1; - - ar>>tmp; - m_bUseDate2=(tmp != 0); - ar>>m_iDateType2; - ar>>tmp; - m_bDate2=(tmp != 0); - ar>>m_tDate2; - ar>>tmp; - m_bTime2=(tmp != 0); - ar>>m_tTime2; - - // attributes - ar>>tmp; - m_bUseAttributes=(tmp != 0); - ar>>m_iArchive; - ar>>m_iReadOnly; - ar>>m_iHidden; - ar>>m_iSystem; - ar>>m_iDirectory; - } + return strMask; } -CString& CFileFilter::GetCombinedMask(CString& pMask) const -{ - pMask.Empty(); - if (m_astrMask.GetSize() > 0) - { - pMask=m_astrMask.GetAt(0); - for (int i=1;i 0) + strMask.Empty(); + if(m_astrExcludeMask.size() > 0) { - pMask=m_astrExcludeMask.GetAt(0); - for (int i=1;i::const_iterator iterMask = m_astrMask.begin(); iterMask != m_astrMask.end(); ++iterMask) { - if (MatchMask(m_astrMask.GetAt(i), rInfo.GetFileName())) - bRes=true; + if(MatchMask(*iterMask, rInfo.GetFileName())) + bRes = true; } - if (!bRes) + if(!bRes) return false; } // excluding mask - if (m_bUseExcludeMask) + if(m_bUseExcludeMask) { - for (int i=0;i::const_iterator iterExcludeMask = m_astrExcludeMask.begin(); iterExcludeMask != m_astrExcludeMask.end(); ++iterExcludeMask) { - if (MatchMask(m_astrExcludeMask.GetAt(i), rInfo.GetFileName())) + if(MatchMask(*iterExcludeMask, rInfo.GetFileName())) return false; } } @@ -577,33 +467,6 @@ return false; } -void CFiltersArray::Serialize(icpf::archive& ar) -{ - if (ar.is_storing()) - { - ar<< m_vFilters.size(); - for(std::vector::iterator iterFilter = m_vFilters.begin(); iterFilter != m_vFilters.end(); iterFilter++) - { - (*iterFilter).Serialize(ar); - } - } - else - { - m_vFilters.clear(); - - size_t stSize; - CFileFilter ff; - - ar >> stSize; - m_vFilters.reserve(stSize); - while(stSize--) - { - ff.Serialize(ar); - m_vFilters.push_back(ff); - } - } -} - bool CFiltersArray::IsEmpty() const { return m_vFilters.empty(); Index: src/ch/FileFilter.h =================================================================== diff -u -N -r449a5b399ab21ca0d06050b47b264f2f704af966 -r5057e08b0cc064972abeb94a488e5f12d9db14a0 --- src/ch/FileFilter.h (.../FileFilter.h) (revision 449a5b399ab21ca0d06050b47b264f2f704af966) +++ src/ch/FileFilter.h (.../FileFilter.h) (revision 5057e08b0cc064972abeb94a488e5f12d9db14a0) @@ -48,20 +48,57 @@ CString& GetCombinedExcludeMask(CString& pMask) const; void SetCombinedExcludeMask(const CString& pMask); - void Serialize(icpf::archive& ar); + template + void serialize(Archive& ar, unsigned int /*uiVersion*/) + { + ar & m_bUseMask; + ar & m_astrMask; + ar & m_bUseExcludeMask; + ar & m_astrExcludeMask; + + ar & m_bUseSize; + ar & m_iSizeType1; + ar & m_ullSize1; + ar & m_bUseSize2; + ar & m_iSizeType2; + ar & m_ullSize2; + + ar & m_bUseDate; + ar & m_iDateType; // created/last modified/last accessed + ar & m_iDateType1; // before/after + ar & m_bDate1; + ar & m_tDate1; + ar & m_bTime1; + ar & m_tTime1; + + ar & m_bUseDate2; + ar & m_iDateType2; + ar & m_bDate2; + ar & m_tDate2; + ar & m_bTime2; + ar & m_tTime2; + + ar & m_bUseAttributes; + ar & m_iArchive; + ar & m_iReadOnly; + ar & m_iHidden; + ar & m_iSystem; + ar & m_iDirectory; + } + protected: bool MatchMask(LPCTSTR lpszMask, LPCTSTR lpszString) const; bool Scan(LPCTSTR& lpszMask, LPCTSTR& lpszString) const; public: // files mask bool m_bUseMask; - CStringArray m_astrMask; + std::vector m_astrMask; // files mask- bool m_bUseExcludeMask; - CStringArray m_astrExcludeMask; + std::vector m_astrExcludeMask; // size filtering bool m_bUseSize; @@ -104,7 +141,13 @@ CFiltersArray& operator=(const CFiltersArray& rSrc); bool Match(const CFileInfo& rInfo) const; - void Serialize(icpf::archive& ar); + + template + void serialize(Archive& ar, unsigned int /*uiVersion*/) + { + ar & m_vFilters; + } + bool IsEmpty() const; void Add(const CFileFilter& rFilter); Index: src/ch/FileInfo.cpp =================================================================== diff -u -N -r3c7ff3a44a80802d86725064af4bf1d5a16bdfc7 -r5057e08b0cc064972abeb94a488e5f12d9db14a0 --- src/ch/FileInfo.cpp (.../FileInfo.cpp) (revision 3c7ff3a44a80802d86725064af4bf1d5a16bdfc7) +++ src/ch/FileInfo.cpp (.../FileInfo.cpp) (revision 5057e08b0cc064972abeb94a488e5f12d9db14a0) @@ -32,6 +32,7 @@ #include "imagehlp.h" #include "ch.h" #include "../libicpf/exception.h" +#include #ifdef _DEBUG #undef THIS_FILE @@ -47,38 +48,6 @@ RemoveAll(); } -void CClipboardArray::Serialize(icpf::archive& ar, bool bData) -{ - if (ar.is_storing()) - { - // write data - int iSize = m_vEntries.size(); - ar<Serialize(ar, bData); - } - else - { - int iSize; - ar>>iSize; - - m_vEntries.reserve(iSize); - CClipboardEntry* pEntry; - for (int i=0;iSerialize(ar, bData); - } - } -} - ////////////////////////////////////////////////////////////////////////////// // CClipboardEntry @@ -99,41 +68,32 @@ { } -CClipboardEntry* CClipboardArray::GetAt(int iPos) +CClipboardEntryPtr CClipboardArray::GetAt(size_t iPos) { return m_vEntries.at(iPos); } -void CClipboardArray::SetAt(int nIndex, CClipboardEntry* pEntry) +void CClipboardArray::SetAt(size_t nIndex, const CClipboardEntryPtr& spEntry) { - delete [] m_vEntries.at(nIndex); - m_vEntries[nIndex] = pEntry; + m_vEntries[nIndex] = spEntry; } -void CClipboardArray::Add(CClipboardEntry* pEntry) +void CClipboardArray::Add(const CClipboardEntryPtr& spEntry) { - m_vEntries.push_back(pEntry); + m_vEntries.push_back(spEntry); } -void CClipboardArray::RemoveAt(int nIndex, int nCount) +void CClipboardArray::RemoveAt(size_t nIndex, size_t nCount) { - while (nCount--) - { - delete m_vEntries.at(nIndex); - } m_vEntries.erase(m_vEntries.begin() + nIndex, m_vEntries.begin() + nIndex + nCount); } void CClipboardArray::RemoveAll() { - for(std::vector::iterator iterEntry = m_vEntries.begin(); iterEntry != m_vEntries.end(); ++iterEntry) - { - delete *iterEntry; - } m_vEntries.clear(); } -int CClipboardArray::GetSize() const +size_t CClipboardArray::GetSize() const { return m_vEntries.size(); } @@ -169,38 +129,6 @@ m_iBufferIndex=BI_DEFAULT; } -void CClipboardEntry::Serialize(icpf::archive& ar, bool bData) -{ - if (bData) - { - if(ar.is_storing()) - { - ar<(m_bMove); - ar<>m_strPath; - unsigned char ucData; - ar>>ucData; - m_bMove=ucData != 0; - ar>>m_iDriveNumber; - ar>>m_uiDriveType; - ar>>m_iBufferIndex; - } - } - else - { - if(ar.is_storing()) - ar << m_vDstPaths; - else - ar >> m_vDstPaths; - } -} - void CClipboardEntry::AddDestinationPath(const CString& strPath) { m_vDstPaths.push_back(strPath); @@ -260,18 +188,26 @@ //////////////////////////////////////////////////////////////////////////// CFileInfo::CFileInfo() : - m_pClipboard(NULL) + m_pClipboard(NULL), + m_strFilePath(), + m_stSrcIndex(std::numeric_limits::max()), + m_dwAttributes(0), + m_uhFileSize(0), + m_uiFlags(0) { + m_ftCreation.dwHighDateTime = m_ftCreation.dwLowDateTime = 0; + m_ftLastAccess.dwHighDateTime = m_ftLastAccess.dwLowDateTime = 0; + m_ftLastWrite.dwHighDateTime = m_ftLastWrite.dwLowDateTime = 0; } CFileInfo::CFileInfo(const CFileInfo& finf) : m_strFilePath(finf.m_strFilePath), - m_iSrcIndex(finf.m_iSrcIndex), + m_stSrcIndex(finf.m_stSrcIndex), m_dwAttributes(finf.m_dwAttributes), m_uhFileSize(finf.m_uhFileSize), - m_timCreation(finf.m_timCreation), - m_timLastAccess(finf.m_timLastAccess), - m_timLastWrite(finf.m_timLastWrite), + m_ftCreation(finf.m_ftCreation), + m_ftLastAccess(finf.m_ftLastAccess), + m_ftLastWrite(finf.m_ftLastWrite), m_uiFlags(finf.m_uiFlags), m_pClipboard(finf.m_pClipboard) { @@ -304,29 +240,29 @@ return false; } -void CFileInfo::Create(const WIN32_FIND_DATA* pwfd, LPCTSTR pszFilePath, int iSrcIndex) +void CFileInfo::Create(const WIN32_FIND_DATA* pwfd, LPCTSTR pszFilePath, size_t stSrcIndex) { - BOOST_ASSERT(iSrcIndex == -1 || m_pClipboard); - if(iSrcIndex != -1 && !m_pClipboard) + BOOST_ASSERT(stSrcIndex == std::numeric_limits::max() || m_pClipboard); + if(stSrcIndex != std::numeric_limits::max() && !m_pClipboard) THROW(_t("Internal error: pointer not initialized."), 0, 0, 0); // copy data from W32_F_D m_strFilePath = CString(pszFilePath) + pwfd->cFileName; // if proper index has been passed - reduce the path - if(m_pClipboard && iSrcIndex >= 0) - m_strFilePath=m_strFilePath.Mid(m_pClipboard->GetAt(iSrcIndex)->GetPath().GetLength()); // wytnij �cie�k� z clipboarda + if(m_pClipboard && stSrcIndex >= 0) + m_strFilePath=m_strFilePath.Mid(m_pClipboard->GetAt(stSrcIndex)->GetPath().GetLength()); // wytnij �cie�k� z clipboarda - m_iSrcIndex=iSrcIndex; + m_stSrcIndex = stSrcIndex; m_dwAttributes = pwfd->dwFileAttributes; m_uhFileSize = (((ULONGLONG) pwfd->nFileSizeHigh) << 32) + pwfd->nFileSizeLow; - m_timCreation = pwfd->ftCreationTime; - m_timLastAccess = pwfd->ftLastAccessTime; - m_timLastWrite = pwfd->ftLastWriteTime; + m_ftCreation = pwfd->ftCreationTime; + m_ftLastAccess = pwfd->ftLastAccessTime; + m_ftLastWrite = pwfd->ftLastWriteTime; m_uiFlags = 0; } -bool CFileInfo::Create(CString strFilePath, int iSrcIndex) +bool CFileInfo::Create(CString strFilePath, size_t stSrcIndex) { WIN32_FIND_DATA wfd; HANDLE hFind; @@ -339,19 +275,19 @@ // add data to members nBarPos = strFilePath.ReverseFind(TCHAR('\\')); - Create(&wfd, strFilePath.Left(nBarPos+1), iSrcIndex); + Create(&wfd, strFilePath.Left(nBarPos+1), stSrcIndex); return true; } else { m_strFilePath=GetResManager().LoadString(IDS_NOTFOUND_STRING); - m_iSrcIndex=-1; + m_stSrcIndex = std::numeric_limits::max(); m_dwAttributes = (DWORD)-1; m_uhFileSize = (unsigned __int64)-1; - m_timCreation.SetDateTime(1900, 1, 1, 0, 0, 0); - m_timLastAccess.SetDateTime(1900, 1, 1, 0, 0, 0); - m_timLastWrite.SetDateTime(1900, 1, 1, 0, 0, 0); + m_ftCreation.dwHighDateTime = m_ftCreation.dwLowDateTime = 0; + m_ftLastAccess.dwHighDateTime = m_ftCreation.dwLowDateTime = 0; + m_ftLastWrite.dwHighDateTime = m_ftCreation.dwLowDateTime = 0; m_uiFlags = 0; return false; } @@ -361,7 +297,7 @@ { ASSERT(m_pClipboard); - CString strPath=(m_iSrcIndex != -1) ? m_pClipboard->GetAt(m_iSrcIndex)->GetPath()+m_strFilePath : m_strFilePath; + CString strPath=(m_stSrcIndex != std::numeric_limits::max()) ? m_pClipboard->GetAt(m_stSrcIndex)->GetPath() + m_strFilePath : m_strFilePath; TCHAR szDrive[_MAX_DRIVE]; _tsplitpath(strPath, szDrive, NULL, NULL, NULL); return CString(szDrive); @@ -371,10 +307,10 @@ { ASSERT(m_pClipboard); - if (m_iSrcIndex != -1) + if(m_stSrcIndex != std::numeric_limits::max()) { // read data stored in CClipboardEntry - return m_pClipboard->GetAt(m_iSrcIndex)->GetDriveNumber(); + return m_pClipboard->GetAt(m_stSrcIndex)->GetDriveNumber(); } else { @@ -389,10 +325,10 @@ { ASSERT(m_pClipboard); - if (m_iSrcIndex != -1) + if (m_stSrcIndex != std::numeric_limits::max()) { // read data contained in CClipboardEntry - return m_pClipboard->GetAt(m_iSrcIndex)->GetDriveType(); + return m_pClipboard->GetAt(m_stSrcIndex)->GetDriveType(); } else { @@ -407,7 +343,7 @@ { ASSERT(m_pClipboard); - CString strPath=(m_iSrcIndex != -1) ? m_pClipboard->GetAt(m_iSrcIndex)->GetPath()+m_strFilePath : m_strFilePath; + CString strPath=(m_stSrcIndex != std::numeric_limits::max()) ? m_pClipboard->GetAt(m_stSrcIndex)->GetPath()+m_strFilePath : m_strFilePath; TCHAR szDir[_MAX_DIR]; _tsplitpath(strPath, NULL, szDir,NULL, NULL); return CString(szDir); @@ -417,7 +353,7 @@ { ASSERT(m_pClipboard); - CString strPath=(m_iSrcIndex != -1) ? m_pClipboard->GetAt(m_iSrcIndex)->GetPath()+m_strFilePath : m_strFilePath; + CString strPath=(m_stSrcIndex != std::numeric_limits::max()) ? m_pClipboard->GetAt(m_stSrcIndex)->GetPath()+m_strFilePath : m_strFilePath; TCHAR szName[_MAX_FNAME]; _tsplitpath(strPath, NULL, NULL, szName, NULL); return CString(szName); @@ -427,7 +363,7 @@ { ASSERT(m_pClipboard); - CString strPath=(m_iSrcIndex != -1) ? m_pClipboard->GetAt(m_iSrcIndex)->GetPath()+m_strFilePath : m_strFilePath; + CString strPath=(m_stSrcIndex != std::numeric_limits::max()) ? m_pClipboard->GetAt(m_stSrcIndex)->GetPath()+m_strFilePath : m_strFilePath; TCHAR szExt[_MAX_EXT]; _tsplitpath(strPath, NULL, NULL, NULL, szExt); return CString(szExt); @@ -437,7 +373,7 @@ { ASSERT(m_pClipboard); - CString strPath=(m_iSrcIndex != -1) ? m_pClipboard->GetAt(m_iSrcIndex)->GetPath()+m_strFilePath : m_strFilePath; + CString strPath=(m_stSrcIndex != std::numeric_limits::max()) ? m_pClipboard->GetAt(m_stSrcIndex)->GetPath()+m_strFilePath : m_strFilePath; TCHAR szDrive[_MAX_DRIVE]; TCHAR szDir[_MAX_DIR]; @@ -447,11 +383,11 @@ CString CFileInfo::GetFileName(void) const { - ASSERT(m_pClipboard || m_iSrcIndex == -1); + ASSERT(m_pClipboard || m_stSrcIndex == std::numeric_limits::max()); CString strPath; - if(m_pClipboard && m_iSrcIndex != -1) - strPath = m_pClipboard->GetAt(m_iSrcIndex)->GetPath() + m_strFilePath; + if(m_pClipboard && m_stSrcIndex != std::numeric_limits::max()) + strPath = m_pClipboard->GetAt(m_stSrcIndex)->GetPath() + m_strFilePath; else strPath = m_strFilePath; @@ -461,38 +397,10 @@ return CString(szName)+szExt; } -void CFileInfo::Store(icpf::archive& ar) -{ - ar<((m_uhFileSize & 0xFFFFFFFF00000000) >> 32); - ar<(m_uhFileSize & 0x00000000FFFFFFFF); - ar<>m_strFilePath; - ar>>m_iSrcIndex; - ar>>m_dwAttributes; - unsigned long part; - ar>>part; - m_uhFileSize=(static_cast(part) << 32); - ar>>part; - m_uhFileSize+=part; - ar>>m_timCreation; - ar>>m_timLastAccess; - ar>>m_timLastWrite; - m_uiFlags = 0; -} - bool CFileInfo::operator==(const CFileInfo& rInfo) { - return (rInfo.m_dwAttributes == m_dwAttributes && rInfo.m_timCreation == m_timCreation - && rInfo.m_timLastWrite == m_timLastWrite && rInfo.m_uhFileSize == m_uhFileSize); + return (rInfo.m_dwAttributes == m_dwAttributes && rInfo.m_ftCreation.dwHighDateTime == m_ftCreation.dwHighDateTime && rInfo.m_ftCreation.dwLowDateTime == m_ftCreation.dwLowDateTime + && rInfo.m_ftLastWrite.dwHighDateTime == m_ftLastWrite.dwHighDateTime && rInfo.m_ftLastWrite.dwLowDateTime == m_ftLastWrite.dwLowDateTime && rInfo.m_uhFileSize == m_uhFileSize); } CString CFileInfo::GetDestinationPath(CString strPath, unsigned char ucCopyNumber, int iFlags) @@ -521,17 +429,17 @@ } else { - if (!(iFlags & 0x01) && m_iSrcIndex != -1) + if (!(iFlags & 0x01) && m_stSrcIndex != std::numeric_limits::max()) { // generate new dest name - while (ucCopyNumber >= m_pClipboard->GetAt(m_iSrcIndex)->GetDestinationPathsCount()) + while (ucCopyNumber >= m_pClipboard->GetAt(m_stSrcIndex)->GetDestinationPathsCount()) { CString strNewPath; FindFreeSubstituteName(GetFullFilePath(), strPath, &strNewPath); - m_pClipboard->GetAt(m_iSrcIndex)->AddDestinationPath(strNewPath); + m_pClipboard->GetAt(m_stSrcIndex)->AddDestinationPath(strNewPath); } - return strPath+m_pClipboard->GetAt(m_iSrcIndex)->GetDestinationPath(ucCopyNumber)+m_strFilePath; + return strPath+m_pClipboard->GetAt(m_stSrcIndex)->GetDestinationPath(ucCopyNumber)+m_strFilePath; } else return strPath+GetFileName(); @@ -541,10 +449,10 @@ CString CFileInfo::GetFullFilePath() const { CString strPath; - if (m_iSrcIndex >= 0) + if(m_stSrcIndex != std::numeric_limits::max()) { ASSERT(m_pClipboard); - strPath+=m_pClipboard->GetAt(m_iSrcIndex)->GetPath(); + strPath+=m_pClipboard->GetAt(m_stSrcIndex)->GetPath(); } strPath+=m_strFilePath; @@ -553,16 +461,16 @@ int CFileInfo::GetBufferIndex() const { - if (m_iSrcIndex != -1) - return m_pClipboard->GetAt(m_iSrcIndex)->GetBufferIndex(); + if (m_stSrcIndex != std::numeric_limits::max()) + return m_pClipboard->GetAt(m_stSrcIndex)->GetBufferIndex(); else return BI_DEFAULT; } /////////////////////////////////////////////////////////////////////// // Array -void CFileInfoArray::AddDir(CString strDirName, const CFiltersArray* pFilters, int iSrcIndex, +void CFileInfoArray::AddDir(CString strDirName, const CFiltersArray* pFilters, size_t stSrcIndex, const bool bRecurse, const bool bIncludeDirs, const volatile bool* pbAbort) { @@ -586,7 +494,7 @@ { if ( !(wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) ) { - finf.Create(&wfd, strDirName, iSrcIndex); + finf.Create(&wfd, strDirName, stSrcIndex); if (pFilters->Match(finf)) m_vFiles.push_back(finf); } @@ -595,14 +503,14 @@ if (bIncludeDirs) { // Add directory itself - finf.Create(&wfd, strDirName, iSrcIndex); + finf.Create(&wfd, strDirName, stSrcIndex); m_vFiles.push_back(finf); } if (bRecurse) { strText = strDirName + wfd.cFileName+_T("\\"); // Recurse Dirs - AddDir(strText, pFilters, iSrcIndex, bRecurse, bIncludeDirs, pbAbort); + AddDir(strText, pFilters, stSrcIndex, bRecurse, bIncludeDirs, pbAbort); } } } @@ -612,16 +520,16 @@ } } -void CFileInfoArray::AddFile(CString strFilePath, int iSrcIndex) +void CFileInfoArray::AddFile(CString strFilePath, size_t stSrcIndex) { - CFileInfo finf; + CFileInfo finf; - // CUSTOMIZATION3 - cut '\\' at the end of strFilePath, set relative path - if (strFilePath.Right(1) == _T("\\")) - strFilePath=strFilePath.Left(strFilePath.GetLength()-1); + // CUSTOMIZATION3 - cut '\\' at the end of strFilePath, set relative path + if(strFilePath.Right(1) == _T("\\")) + strFilePath = strFilePath.Left(strFilePath.GetLength()-1); - finf.Create(strFilePath, iSrcIndex); - return m_vFiles.push_back(finf); + finf.Create(strFilePath, stSrcIndex); + return m_vFiles.push_back(finf); } void CFileInfoArray::AddFileInfo(const CFileInfo& rFileInfo) @@ -648,53 +556,3 @@ { m_vFiles.clear(); } - -void CFileInfoArray::Store(icpf::archive& ar, bool bOnlyFlags) -{ - INT_PTR iSize = m_vFiles.size(); - ar << iSize; - for (std::vector::iterator iterFile = m_vFiles.begin(); iterFile != m_vFiles.end(); ++iterFile) - { - if(bOnlyFlags) - ar << (*iterFile).GetFlags(); - else - (*iterFile).Store(ar); - } -} - -void CFileInfoArray::Load(icpf::archive& ar, bool bOnlyFlags) -{ - INT_PTR iSize; - ar>>iSize; - - // workaround for a problem, where '0' was stored as int instead of INT_PTR; - // in this case on x86_64 iSize could have some enormous size (because we read - // someone else's data following the int value. - // Try to avoid reading later some invalid data (since we have stolen 4 bytes on x86_64). - if(iSize > INT_MAX) - THROW(_T("[CFileInfoArray::Load()] Corrupted task data (bug [#sf:2905339]"), 0, 0, 0); - - if(!bOnlyFlags) - { - m_vFiles.clear(); - m_vFiles.reserve(iSize); - } - - CFileInfo fi; - fi.SetClipboard(&m_rClipboard); - uint_t uiFlags = 0; - for (INT_PTR i = 0; i < iSize; i++) - { - if(bOnlyFlags) - { - CFileInfo& rInfo = m_vFiles.at(i); - ar >> uiFlags; - rInfo.SetFlags(uiFlags); - } - else - { - fi.Load(ar); - m_vFiles.push_back(fi); - } - } -} Index: src/ch/FileInfo.h =================================================================== diff -u -N -r8cb15f097b81ca387f3ae122dd355f3c397b7842 -r5057e08b0cc064972abeb94a488e5f12d9db14a0 --- src/ch/FileInfo.h (.../FileInfo.h) (revision 8cb15f097b81ca387f3ae122dd355f3c397b7842) +++ src/ch/FileInfo.h (.../FileInfo.h) (revision 5057e08b0cc064972abeb94a488e5f12d9db14a0) @@ -23,6 +23,8 @@ #define __FILEINFO_H__ #include "DestPath.h" +#include +#include void FindFreeSubstituteName(CString strSrcPath, CString strDstPath, CString* pstrResult); extern void GetDriveData(LPCTSTR lpszPath, int *piDrvNum, UINT *puiDrvType); @@ -52,7 +54,20 @@ int GetBufferIndex() const { return m_iBufferIndex; } - void Serialize(icpf::archive& ar, bool bData); + template + void Serialize(Archive& ar, unsigned int /*uiVersion*/, bool bData) + { + if(bData) + { + ar & m_strPath; + ar & m_bMove; + ar & m_iDriveNumber; + ar & m_uiDriveType; + ar & m_iBufferIndex; + } + else + ar & m_vDstPaths; + } void AddDestinationPath(const CString& strPath); size_t GetDestinationPathsCount() const; @@ -70,26 +85,68 @@ std::vector m_vDstPaths; // dest paths table for this group of paths }; +typedef boost::shared_ptr CClipboardEntryPtr; + ////////////////////////////////////////////////////////////////////////// // CClipboardArray class CClipboardArray { public: ~CClipboardArray(); - - void Serialize(icpf::archive& ar, bool bData); - CClipboardEntry* GetAt(int iPos); + template + void Store(Archive& ar, unsigned int /*uiVersion*/, bool bData) + { + // write data + size_t stCount = m_vEntries.size(); + ar << stCount; + + BOOST_FOREACH(CClipboardEntryPtr& spEntry, m_vEntries) + { + spEntry->Serialize(ar, 0, bData); + } + } - int GetSize() const; - void Add(CClipboardEntry* pEntry); - void SetAt(int nIndex, CClipboardEntry* pEntry); - void RemoveAt(int nIndex, int nCount = 1); + template + void Load(Archive& ar, unsigned int /*uiVersion*/, bool bData) + { + size_t stCount; + ar >> stCount; + + if(!bData && m_vEntries.size() != stCount) + THROW(_T("Count of entries with data differs from the count of state entries"), 0, 0, 0); + + if(bData) + { + m_vEntries.clear(); + m_vEntries.reserve(stCount); + } + + CClipboardEntryPtr spEntry; + for(size_t stIndex = 0; stIndex < stCount; ++stIndex) + { + if(bData) + spEntry.reset(new CClipboardEntry); + else + spEntry = m_vEntries.at(stIndex); + spEntry->Serialize(ar, 0, bData); + + if(bData) + m_vEntries.push_back(spEntry); + } + } + + CClipboardEntryPtr GetAt(size_t iPos); + + size_t GetSize() const; + void Add(const CClipboardEntryPtr& pEntry); + void SetAt(size_t nIndex, const CClipboardEntryPtr& pEntry); + void RemoveAt(size_t nIndex, size_t nCount = 1); void RemoveAll(); protected: - std::vector m_vEntries; + std::vector m_vEntries; }; class CFileInfo @@ -101,33 +158,33 @@ // static member static bool Exist(CString strPath); // check for file or folder existence - - void Create(const WIN32_FIND_DATA* pwfd, LPCTSTR pszFilePath, int iSrcIndex); - bool Create(CString strFilePath, int iSrcIndex); - + + void Create(const WIN32_FIND_DATA* pwfd, LPCTSTR pszFilePath, size_t stSrcIndex); + bool Create(CString strFilePath, size_t stSrcIndex); + ULONGLONG GetLength64() const { return m_uhFileSize; } void SetLength64(ULONGLONG uhSize) { m_uhFileSize=uhSize; } // disk - path and disk number (-1 if none - ie. net disk) CString GetFileDrive(void) const; // returns string with src disk int GetDriveNumber() const; // disk number A - 0, b-1, c-2, ... UINT GetDriveType() const; // drive type - + CString GetFileDir() const; // @rdesc Returns \WINDOWS\ for C:\WINDOWS\WIN.INI CString GetFileTitle() const; // @cmember returns WIN for C:\WINDOWS\WIN.INI CString GetFileExt() const; /** @cmember returns INI for C:\WINDOWS\WIN.INI */ CString GetFileRoot() const; /** @cmember returns C:\WINDOWS\ for C:\WINDOWS\WIN.INI */ CString GetFileName() const; /** @cmember returns WIN.INI for C:\WINDOWS\WIN.INI */ - + const CString& GetFilePath(void) const { return m_strFilePath; } // returns path with m_strFilePath (probably not full) CString GetFullFilePath() const; /** @cmember returns C:\WINDOWS\WIN.INI for C:\WINDOWS\WIN.INI */ void SetFilePath(LPCTSTR lpszPath) { m_strFilePath=lpszPath; }; - + /* Get File times info (equivalent to CFindFile members) */ - const COleDateTime& GetCreationTime() const { return m_timCreation; }; - const COleDateTime& GetLastAccessTime() const { return m_timLastAccess; }; - const COleDateTime& GetLastWriteTime() const { return m_timLastWrite; }; - + const FILETIME& GetCreationTime() const { return m_ftCreation; }; + const FILETIME& GetLastAccessTime() const { return m_ftLastAccess; }; + const FILETIME& GetLastWriteTime() const { return m_ftLastWrite; }; + /* Get File attributes info (equivalent to CFindFile members) */ DWORD GetAttributes(void) const { return m_dwAttributes; } bool IsDirectory(void) const { return (m_dwAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0; } @@ -146,29 +203,41 @@ void SetClipboard(CClipboardArray *pClipboard) { m_pClipboard=pClipboard; }; CString GetDestinationPath(CString strPath, unsigned char ucCopyNumber, int iFlags); - void SetSrcIndex(int iIndex) { m_iSrcIndex=iIndex; }; - int GetSrcIndex() const { return m_iSrcIndex; }; + void SetSrcIndex(int iIndex) { m_stSrcIndex=iIndex; }; + size_t GetSrcIndex() const { return m_stSrcIndex; }; - bool GetMove() { if (m_iSrcIndex != -1) return m_pClipboard->GetAt(m_iSrcIndex)->GetMove(); else return true; }; + bool GetMove() { if (m_stSrcIndex != -1) return m_pClipboard->GetAt(m_stSrcIndex)->GetMove(); else return true; }; int GetBufferIndex() const; // operators bool operator==(const CFileInfo& rInfo); - - // (re)/store data - void Store(icpf::archive& ar); - void Load(icpf::archive& ar); + template + void serialize(Archive& ar, unsigned int /*uiVersion*/) + { + ar & m_strFilePath; + ar & m_stSrcIndex; + ar & m_dwAttributes; + ar & m_uhFileSize; + ar & m_ftCreation.dwHighDateTime; + ar & m_ftCreation.dwLowDateTime; + ar & m_ftLastAccess.dwHighDateTime; + ar & m_ftLastAccess.dwLowDateTime; + ar & m_ftLastWrite.dwHighDateTime; + ar & m_ftLastWrite.dwLowDateTime; + ar & m_uiFlags; + } + private: CString m_strFilePath; // contains relative path (first path is in CClipboardArray) - int m_iSrcIndex; // index in CClipboardArray table (which contains the first part of the path) - + size_t m_stSrcIndex; // index in CClipboardArray table (which contains the first part of the path) + DWORD m_dwAttributes; // attributes ULONGLONG m_uhFileSize; - COleDateTime m_timCreation; - COleDateTime m_timLastAccess; - COleDateTime m_timLastWrite; + FILETIME m_ftCreation; + FILETIME m_ftLastAccess; + FILETIME m_ftLastWrite; uint_t m_uiFlags; // ptrs to elements providing data @@ -182,15 +251,15 @@ { public: CFileInfoArray(CClipboardArray& A_rClipboardArray) : - m_rClipboard(A_rClipboardArray) + m_rClipboard(A_rClipboardArray) { } - void AddDir(CString strDirName, const CFiltersArray* pFilters, int iSrcIndex, - const bool bRecurse, const bool bIncludeDirs, const volatile bool* pbAbort=NULL); - - void AddFile(CString strFilePath, int iSrcIndex); - + void AddDir(CString strDirName, const CFiltersArray* pFilters, size_t stSrcIndex, + const bool bRecurse, const bool bIncludeDirs, const volatile bool* pbAbort=NULL); + + void AddFile(CString strFilePath, size_t stSrcIndex); + void AddFileInfo(const CFileInfo& rFileInfo); void AppendArray(const CFileInfoArray& arrFiles); @@ -201,13 +270,59 @@ void Clear(); // store/restore - void Store(icpf::archive& ar, bool bOnlyFlags); + template + void Store(Archive& ar, unsigned int /*uiVersion*/, bool bOnlyFlags) + { + size_t stCount = m_vFiles.size(); + ar << stCount; + for(std::vector::iterator iterFile = m_vFiles.begin(); iterFile != m_vFiles.end(); ++iterFile) + { + if(bOnlyFlags) + { + uint_t uiFlags = (*iterFile).GetFlags(); + ar << uiFlags; + } + else + ar << (*iterFile); + } + } - void Load(icpf::archive& ar, bool bOnlyFlags); + template + void Load(Archive& ar, unsigned int /*uiVersion*/, bool bOnlyFlags) + { + size_t stCount; + ar >> stCount; + if(!bOnlyFlags) + { + m_vFiles.clear(); + m_vFiles.reserve(stCount); + } + else if(stCount != m_vFiles.size()) + THROW(_T("Invalid count of flags received"), 0, 0, 0); + + CFileInfo fi; + fi.SetClipboard(&m_rClipboard); + uint_t uiFlags = 0; + for(size_t stIndex = 0; stIndex < stCount; stIndex++) + { + if(bOnlyFlags) + { + CFileInfo& rInfo = m_vFiles.at(stIndex); + ar >> uiFlags; + rInfo.SetFlags(uiFlags); + } + else + { + ar >> fi; + m_vFiles.push_back(fi); + } + } + } + protected: CClipboardArray& m_rClipboard; std::vector m_vFiles; }; - + #endif Index: src/ch/MainWnd.cpp =================================================================== diff -u -N -rbeeac49d2e0888993bd231a4e5863c7f0741e154 -r5057e08b0cc064972abeb94a488e5f12d9db14a0 --- src/ch/MainWnd.cpp (.../MainWnd.cpp) (revision beeac49d2e0888993bd231a4e5863c7f0741e154) +++ src/ch/MainWnd.cpp (.../MainWnd.cpp) (revision 5057e08b0cc064972abeb94a488e5f12d9db14a0) @@ -35,6 +35,8 @@ #include "StatusDlg.h" #include "ClipboardMonitor.h" +#include + #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE @@ -389,9 +391,9 @@ KillTimer(3245); if (GetConfig().get_bool(PP_STATUSAUTOREMOVEFINISHED)) { - int iSize=m_tasks.GetSize(); + size_t stSize = m_tasks.GetSize(); m_tasks.RemoveAllFinished(); - if (m_tasks.GetSize() != iSize && m_pdlgStatus && m_pdlgStatus->m_bLock && IsWindow(m_pdlgStatus->m_hWnd)) + if(m_tasks.GetSize() != stSize && m_pdlgStatus && m_pdlgStatus->m_bLock && IsWindow(m_pdlgStatus->m_hWnd)) m_pdlgStatus->SendMessage(WM_UPDATESTATUS); } @@ -541,15 +543,15 @@ // create new task CTask *pTask = m_tasks.CreateTask(); pTask->SetDestPath(strDstPath); - CClipboardEntry* pEntry; + CClipboardEntryPtr spEntry; // files for (int i=0;iSetPath(astrFiles.GetAt(i)); - pEntry->CalcBufferIndex(pTask->GetDestPath()); - pTask->AddClipboardData(pEntry); + spEntry.reset(new CClipboardEntry); + spEntry->SetPath(astrFiles.GetAt(i)); + spEntry->CalcBufferIndex(pTask->GetDestPath()); + pTask->AddClipboardData(spEntry); } pTask->SetStatus(bMove ? ST_MOVE : ST_COPY, ST_OPERATION_MASK); @@ -626,13 +628,13 @@ // new task CTask *pTask = m_tasks.CreateTask(); pTask->SetDestPath(dlg.m_ccData.m_strDestPath); - CClipboardEntry *pEntry; + CClipboardEntryPtr spEntry; for (int i=0;iSetPath(dlg.m_ccData.m_astrPaths.GetAt(i)); - pEntry->CalcBufferIndex(pTask->GetDestPath()); - pTask->AddClipboardData(pEntry); + spEntry.reset(new CClipboardEntry); + spEntry->SetPath(dlg.m_ccData.m_astrPaths.GetAt(i)); + spEntry->CalcBufferIndex(pTask->GetDestPath()); + pTask->AddClipboardData(spEntry); } pTask->SetStatus((dlg.m_ccData.m_iOperation == 1) ? ST_MOVE : ST_COPY, ST_OPERATION_MASK); @@ -764,7 +766,7 @@ } // count of shortcuts to store - g_pscsShared->iShortcutsCount=__min(cvShortcuts.size(), (SHARED_BUFFERSIZE - 5 * sizeof(_COMMAND)) / sizeof(_SHORTCUT)); + g_pscsShared->iShortcutsCount = (int)__min(cvShortcuts.size(), (SHARED_BUFFERSIZE - 5 * sizeof(_COMMAND)) / sizeof(_SHORTCUT)); _SHORTCUT* pShortcut = g_pscsShared->GetShortcutsPtr(); CShortcut sc; for (int i=0;iiShortcutsCount;i++) @@ -939,9 +941,11 @@ m_tasks.SaveProgress(); // delete all tasks - int iSize=m_tasks.GetSize(); - for (int i=0;i* >(&m_tasks))->RemoveAll(); } Index: src/ch/ProgressListBox.cpp =================================================================== diff -u -N -ra07af504f54ceb5551be875f0f42e3134d57fabc -r5057e08b0cc064972abeb94a488e5f12d9db14a0 --- src/ch/ProgressListBox.cpp (.../ProgressListBox.cpp) (revision a07af504f54ceb5551be875f0f42e3134d57fabc) +++ src/ch/ProgressListBox.cpp (.../ProgressListBox.cpp) (revision 5057e08b0cc064972abeb94a488e5f12d9db14a0) @@ -151,7 +151,7 @@ void CProgressListBox::RecalcHeight() { // new height - int iCtlHeight=m_vItems.size()*GetItemHeight(0); + int iCtlHeight = (int)m_vItems.size() * GetItemHeight(0); // change control size CRect rcCtl; @@ -200,8 +200,8 @@ while (GetCount() < m_vItems.size()) AddString(_T("")); - while (GetCount() > m_vItems.size()) - DeleteString(m_vItems.size()); + while (GetCount() > (int)m_vItems.size()) + DeleteString((UINT)m_vItems.size()); } if (bUpdateSize) Index: src/ch/SerializationHelpers.h =================================================================== diff -u -N --- src/ch/SerializationHelpers.h (revision 0) +++ src/ch/SerializationHelpers.h (revision 5057e08b0cc064972abeb94a488e5f12d9db14a0) @@ -0,0 +1,65 @@ +/*************************************************************************** +* 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 __SERIALIZATION_HELPERS_H__ +#define __SERIALIZATION_HELPERS_H__ + +#include +#include + +BOOST_SERIALIZATION_SPLIT_FREE(CString); +BOOST_SERIALIZATION_SPLIT_FREE(CTime); + +namespace boost { + namespace serialization { + + template + void save(Archive& ar, const CString& str, const unsigned int /*version*/) + { + std::wstring wstr = str; + ar << wstr; + } + + template + void load(Archive& ar, CString& str, const unsigned int /*version*/) + { + std::wstring wstr; + ar >> wstr; + str = wstr.c_str(); + } + + template + void save(Archive& ar, const CTime& tTime, const unsigned int /*version*/) + { + long long llTime = tTime.GetTime(); + ar << llTime; + } + + template + void load(Archive& ar, CTime& tTime, const unsigned int /*version*/) + { + long long llTime = 0; + ar >> llTime; + tTime = CTime(llTime); + } + + } // namespace serialization +} // namespace boost + + +#endif Index: src/ch/StatusDlg.cpp =================================================================== diff -u -N -r11621f18af6a7b1d486a7d6a576b97d4d09e8e96 -r5057e08b0cc064972abeb94a488e5f12d9db14a0 --- src/ch/StatusDlg.cpp (.../StatusDlg.cpp) (revision 11621f18af6a7b1d486a7d6a576b97d4d09e8e96) +++ src/ch/StatusDlg.cpp (.../StatusDlg.cpp) (revision 5057e08b0cc064972abeb94a488e5f12d9db14a0) @@ -294,7 +294,7 @@ } // count of processed data/overall count of data - _sntprintf(m_szData, _MAX_PATH, _T("%d/%d ("), td.m_iIndex, td.m_iSize); + _sntprintf(m_szData, _MAX_PATH, _T("%d/%d ("), td.m_stIndex, td.m_stSize); m_strTemp=CString(m_szData); m_strTemp+=GetSizeString(td.m_ullProcessedSize, m_szData, _MAX_PATH)+CString(_T("/")); m_strTemp+=GetSizeString(td.m_ullSizeAll, m_szData, _MAX_PATH)+CString(_T(")")); @@ -320,7 +320,7 @@ FormatTime(td.m_lTimeElapsed, m_szTimeBuffer1, 40); long lTotalTime = (td.m_ullProcessedSize == 0) ? 0 : (long)(td.m_ullSizeAll * td.m_lTimeElapsed / td.m_ullProcessedSize); FormatTime(lTotalTime, m_szTimeBuffer2, 40); - FormatTime(max(0, lTotalTime - td.m_lTimeElapsed), m_szTimeBuffer3, 40); + FormatTime(std::max(0l, lTotalTime - td.m_lTimeElapsed), m_szTimeBuffer3, 40); _sntprintf(m_szData, _MAX_PATH, _T("%s / %s (%s)"), m_szTimeBuffer1, m_szTimeBuffer2, m_szTimeBuffer3); GetDlgItem(IDC_TIME_STATIC)->SetWindowText(m_szData); @@ -737,7 +737,7 @@ DWORD dwCurrentTime=GetTickCount(); // get rid of item after the current part - m_ctlStatusList.LimitItems(m_pTasks->GetSize()); + m_ctlStatusList.LimitItems((int)m_pTasks->GetSize()); // add task info for (int i=0;iGetSize();i++) Index: src/ch/Stdafx.h =================================================================== diff -u -N -r2457755b4084e3d1c80a8e7c77c9f0996312941b -r5057e08b0cc064972abeb94a488e5f12d9db14a0 --- src/ch/Stdafx.h (.../Stdafx.h) (revision 2457755b4084e3d1c80a8e7c77c9f0996312941b) +++ src/ch/Stdafx.h (.../Stdafx.h) (revision 5057e08b0cc064972abeb94a488e5f12d9db14a0) @@ -20,6 +20,7 @@ #define __STDAFX_H__ #define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers +#define NOMINMAX #include "../common/targetver.h" @@ -40,6 +41,7 @@ #include #include "../common/ErrorConstants.h" #include "../libchcore/TLogger.h" +#include "SerializationHelpers.h" #ifdef _UNICODE #if defined _M_IX86 Index: src/ch/UpdateChecker.cpp =================================================================== diff -u -N -r5b177c8d202751958cb04cd3049549a94aab5994 -r5057e08b0cc064972abeb94a488e5f12d9db14a0 --- src/ch/UpdateChecker.cpp (.../UpdateChecker.cpp) (revision 5b177c8d202751958cb04cd3049549a94aab5994) +++ src/ch/UpdateChecker.cpp (.../UpdateChecker.cpp) (revision 5057e08b0cc064972abeb94a488e5f12d9db14a0) @@ -207,8 +207,8 @@ memset(&m_internetBuffers, 0, sizeof(INTERNET_BUFFERS)); m_internetBuffers.dwStructSize = sizeof(INTERNET_BUFFERS); - m_internetBuffers.dwBufferLength = stSize; - m_internetBuffers.dwBufferTotal = stSize; + m_internetBuffers.dwBufferLength = (DWORD)stSize; + m_internetBuffers.dwBufferTotal = (DWORD)stSize; m_internetBuffers.lpvBuffer = pBuffer; m_dwExpectedState = INTERNET_STATUS_REQUEST_COMPLETE; Index: src/ch/ch.vc90.vcproj =================================================================== diff -u -N -ra2c7c034afa5154e0e7d4aff72fdd8d5685e7e9c -r5057e08b0cc064972abeb94a488e5f12d9db14a0 --- src/ch/ch.vc90.vcproj (.../ch.vc90.vcproj) (revision a2c7c034afa5154e0e7d4aff72fdd8d5685e7e9c) +++ src/ch/ch.vc90.vcproj (.../ch.vc90.vcproj) (revision 5057e08b0cc064972abeb94a488e5f12d9db14a0) @@ -54,7 +54,7 @@ AdditionalOptions="/analyze" Optimization="0" AdditionalIncludeDirectories="..\libicpf\src" - PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_BIND_TO_CURRENT_VCLIBS_VERSION=1" + PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_BIND_TO_CURRENT_VCLIBS_VERSION=1;_SCL_SECURE_NO_WARNINGS" BasicRuntimeChecks="3" RuntimeLibrary="3" UsePrecompiledHeader="2" @@ -146,7 +146,7 @@ AdditionalOptions="/analyze" Optimization="0" AdditionalIncludeDirectories="..\libicpf\src" - PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_BIND_TO_CURRENT_VCLIBS_VERSION=1" + PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_BIND_TO_CURRENT_VCLIBS_VERSION=1;_SCL_SECURE_NO_WARNINGS" BasicRuntimeChecks="3" RuntimeLibrary="3" UsePrecompiledHeader="2" @@ -238,7 +238,7 @@ Optimization="2" InlineFunctionExpansion="2" AdditionalIncludeDirectories="..\libicpf\src" - PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_BIND_TO_CURRENT_VCLIBS_VERSION=1" + PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_BIND_TO_CURRENT_VCLIBS_VERSION=1;_SCL_SECURE_NO_WARNINGS" StringPooling="true" RuntimeLibrary="2" EnableFunctionLevelLinking="true" @@ -331,7 +331,7 @@ Optimization="0" InlineFunctionExpansion="2" AdditionalIncludeDirectories="..\libicpf\src" - PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_BIND_TO_CURRENT_VCLIBS_VERSION=1" + PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_BIND_TO_CURRENT_VCLIBS_VERSION=1;_SCL_SECURE_NO_WARNINGS" StringPooling="true" RuntimeLibrary="2" EnableFunctionLevelLinking="true" @@ -469,6 +469,10 @@ > + + @@ -1787,7 +1791,7 @@ @@ -1797,7 +1801,7 @@ @@ -1807,7 +1811,7 @@ @@ -1817,7 +1821,7 @@ @@ -2587,7 +2591,7 @@ @@ -2597,7 +2601,7 @@ @@ -2607,7 +2611,7 @@ @@ -2617,7 +2621,7 @@ Index: src/ch/task.cpp =================================================================== diff -u -N -r3c7ff3a44a80802d86725064af4bf1d5a16bdfc7 -r5057e08b0cc064972abeb94a488e5f12d9db14a0 --- src/ch/task.cpp (.../task.cpp) (revision 3c7ff3a44a80802d86725064af4bf1d5a16bdfc7) +++ src/ch/task.cpp (.../task.cpp) (revision 5057e08b0cc064972abeb94a488e5f12d9db14a0) @@ -22,6 +22,10 @@ #include "../common/FileSupport.h" #include "ch.h" #include "FeedbackHandler.h" +#include +#include +#include +#include // assume max sectors of 4kB (for rounding) #define MAXSECTORSIZE 4096 @@ -64,8 +68,8 @@ m_log(), m_piFeedbackHandler(piFeedbackHandler), m_files(m_clipboard), - m_nCurrentIndex(0), - m_iLastProcessedIndex(-1), + m_stCurrentIndex(0), + m_stLastProcessedIndex(0), m_nStatus(ST_NULL_STATUS), m_pThread(NULL), m_nPriority(THREAD_PRIORITY_NORMAL), @@ -109,26 +113,26 @@ } // m_clipboard -void CTask::AddClipboardData(CClipboardEntry* pEntry) +void CTask::AddClipboardData(const CClipboardEntryPtr& spEntry) { m_cs.Lock(); - m_clipboard.Add(pEntry); + m_clipboard.Add(spEntry); m_cs.Unlock(); } -CClipboardEntry* CTask::GetClipboardData(int nIndex) +CClipboardEntryPtr CTask::GetClipboardData(size_t stIndex) { m_cs.Lock(); - CClipboardEntry* pEntry=m_clipboard.GetAt(nIndex); + CClipboardEntryPtr spEntry = m_clipboard.GetAt(stIndex); m_cs.Unlock(); - return pEntry; + return spEntry; } -int CTask::GetClipboardDataSize() +size_t CTask::GetClipboardDataSize() { m_cs.Lock(); - int rv=m_clipboard.GetSize(); + size_t rv=m_clipboard.GetSize(); m_cs.Unlock(); return rv; @@ -145,16 +149,16 @@ m_cs.Lock(); for (int i=0;iGetPath(); + CClipboardEntryPtr spEntry = m_clipboard.GetAt(i); + strText = spEntry->GetPath(); strText.MakeLower(); iOffset=strText.Find(strOld, 0); if (iOffset != -1) { // found - strText=pEntry->GetPath(); - strText=strText.Left(iOffset)+strNew+strText.Mid(iOffset+strOld.GetLength()); - pEntry->SetPath(strText); + strText = spEntry->GetPath(); + strText = strText.Left(iOffset)+strNew+strText.Mid(iOffset+strOld.GetLength()); + spEntry->SetPath(strText); iCount++; } } @@ -164,13 +168,13 @@ } // m_files -int CTask::FilesAddDir(const CString strDirName, const CFiltersArray* pFilters, int iSrcIndex, - const bool bRecurse, const bool bIncludeDirs) +int CTask::FilesAddDir(const CString strDirName, const CFiltersArray* pFilters, size_t stSrcIndex, + const bool bRecurse, const bool bIncludeDirs) { // this uses much of memory, but resolves problem critical section hungs and m_bKill CFileInfoArray fa(m_clipboard); - fa.AddDir(strDirName, pFilters, iSrcIndex, bRecurse, bIncludeDirs, &m_bKill); + fa.AddDir(strDirName, pFilters, stSrcIndex, bRecurse, bIncludeDirs, &m_bKill); m_cs.Lock(); @@ -189,10 +193,10 @@ m_cs.Unlock(); } -CFileInfo CTask::FilesGetAt(int nIndex) +CFileInfo CTask::FilesGetAt(size_t stIndex) { m_cs.Lock(); - CFileInfo info=m_files.GetAt(nIndex); + CFileInfo info = m_files.GetAt(stIndex); m_cs.Unlock(); return info; @@ -201,7 +205,7 @@ CFileInfo& CTask::FilesGetAtCurrentIndex() { m_cs.Lock(); - CFileInfo& info=m_files.GetAt(m_nCurrentIndex); + CFileInfo& info = m_files.GetAt(m_stCurrentIndex); m_cs.Unlock(); return info; } @@ -222,27 +226,27 @@ return nSize; } -// m_nCurrentIndex +// m_stCurrentIndex void CTask::IncreaseCurrentIndex() { m_cs.Lock(); - ++m_nCurrentIndex; + ++m_stCurrentIndex; m_cs.Unlock(); } -int CTask::GetCurrentIndex() +size_t CTask::GetCurrentIndex() { m_cs.Lock(); - int nIndex=m_nCurrentIndex; + size_t stIndex = m_stCurrentIndex; m_cs.Unlock(); - return nIndex; + return stIndex; } -void CTask::SetCurrentIndex(int nIndex) +void CTask::SetCurrentIndex(size_t stIndex) { m_cs.Lock(); - m_nCurrentIndex=nIndex; + m_stCurrentIndex = stIndex; m_cs.Unlock(); } @@ -303,9 +307,9 @@ { int rv=0; m_cs.Lock(); - int iSize=m_files.GetSize(); - if (iSize > 0 && m_nCurrentIndex != -1) - rv=m_bsSizes.m_bOnlyDefault ? 0 : m_files.GetAt((m_nCurrentIndex < iSize) ? m_nCurrentIndex : 0).GetBufferIndex(); + size_t stSize = m_files.GetSize(); + if (stSize > 0 && m_stCurrentIndex != -1) + rv=m_bsSizes.m_bOnlyDefault ? 0 : m_files.GetAt((m_stCurrentIndex < stSize) ? m_stCurrentIndex : 0).GetBufferIndex(); m_cs.Unlock(); return rv; @@ -382,8 +386,8 @@ m_cs.Lock(); m_nAll=0; - int nSize=m_files.GetSize(); - for (int i=0;i>m_strUniqueName; - m_afFilters.Serialize(ar); - ar>>m_ucCopies; + m_files.Load(ar, 0, false); + + ar >> m_dpDestPath; + + ar >> m_strUniqueName; + ar >> m_afFilters; + ar >> m_ucCopies; } else { - int data; - unsigned long part; + size_t stData = 0; + UINT uiData = 0; - ar>>data; - m_nCurrentIndex=data; - ar>>data; - m_nStatus=data; - ar>>m_lOsError; - ar>>m_strErrorDesc; - m_bsSizes.Serialize(ar); - ar>>m_nPriority; + ar >> stData; + m_stCurrentIndex = stData; + ar >> uiData; + m_nStatus = uiData; + ar >> m_lOsError; - ar>>part; - m_nAll=(static_cast(part) << 32); - ar>>part; - m_nAll|=part; - // czas - ar>>m_lTimeElapsed; + ar >> m_strErrorDesc; - ar>>part; - m_nProcessed=(static_cast(part) << 32); - ar>>part; - m_nProcessed|=part; + ar >> m_bsSizes; + ar >> m_nPriority; + ar >> m_nAll; + ar >> m_lTimeElapsed; - ar>>m_ucCurrentCopy; + ar >> m_nProcessed; + ar >> m_ucCurrentCopy; - m_clipboard.Serialize(ar, bData); - m_files.Load(ar, true); + m_clipboard.Load(ar, 0, bData); + m_files.Load(ar, 0, true); - unsigned char ucTmp; - ar>>ucTmp; - m_bSaved=ucTmp != 0; + ar >> m_bSaved; } } - catch(icpf::exception&) + catch(...) { m_cs.Unlock(); throw; @@ -571,59 +571,67 @@ return; } - if (!bData && !m_bSaved && ( (m_nStatus & ST_STEP_MASK) == ST_FINISHED || (m_nStatus & ST_STEP_MASK) == ST_CANCELLED + if(!bData && !m_bSaved && ( (m_nStatus & ST_STEP_MASK) == ST_FINISHED || (m_nStatus & ST_STEP_MASK) == ST_CANCELLED || (m_nStatus & ST_WORKING_MASK) == ST_PAUSED )) { TRACE("Last save - saving blocked\n"); - m_bSaved=true; + m_bSaved = true; } try { - CString strPath = m_strTaskBasePath.c_str() + GetUniqueName()+( (bData) ? _T(".atd") : _T(".atp") ); - icpf::archive ar; - ar.open(strPath, FA_WRITE | FA_CREATE | FA_TRUNCATE); - ar.datablock_begin(); + CString strPath = m_strTaskBasePath.c_str() + GetUniqueName() + (bData ? _T(".atd") : _T(".atp")); - if (bData) + std::ofstream ofs(strPath); + boost::archive::binary_oarchive ar(ofs); + + if(bData) { - m_clipboard.Serialize(ar, bData); + m_clipboard.Store(ar, 0, bData); - if (GetStatus(ST_STEP_MASK) > ST_SEARCHING) - m_files.Store(ar, false); + if(GetStatus(ST_STEP_MASK) > ST_SEARCHING) + m_files.Store(ar, 0, false); else - ar<(0); + { + size_t st(0); + ar << st; + } - m_dpDestPath.Serialize(ar); - ar<((m_nAll & 0xffffffff00000000) >> 32); - ar<(m_nAll & 0x00000000ffffffff); - ar<((m_nProcessed & 0xffffffff00000000) >> 32); - ar<(m_nProcessed & 0x00000000ffffffff); - ar< ST_SEARCHING) - m_files.Store(ar, true); + size_t stCurrentIndex = m_stCurrentIndex; + ar << stCurrentIndex; + UINT uiStatus = (m_nStatus & ST_WRITE_MASK); + ar << uiStatus; + ar << m_lOsError; + + ar << m_strErrorDesc; + + ar << m_bsSizes; + ar << m_nPriority; + ar << m_nAll; + ar << m_lTimeElapsed; + + ar << m_nProcessed; + ar << m_ucCurrentCopy; + + m_clipboard.Store(ar, 0, bData); + if(GetStatus(ST_STEP_MASK) > ST_SEARCHING) + m_files.Store(ar, 0, true); else - ar<(0); - ar<<(unsigned char)m_bSaved; + { + size_t st(0); + ar << st; + } + ar << m_bSaved; } - ar.datablock_end(); - ar.close(); } - catch(icpf::exception& /*e*/) + catch(...) { m_cs.Unlock(); return; @@ -736,8 +744,8 @@ void CTask::GetMiniSnapshot(TASK_MINI_DISPLAY_DATA *pData) { m_cs.Lock(); - if (m_nCurrentIndex >= 0 && m_nCurrentIndex < m_files.GetSize()) - pData->m_fi=m_files.GetAt(m_nCurrentIndex); + if (m_stCurrentIndex >= 0 && m_stCurrentIndex < m_files.GetSize()) + pData->m_fi=m_files.GetAt(m_stCurrentIndex); else { if (m_files.GetSize() > 0) @@ -764,13 +772,13 @@ pData->m_uiStatus=m_nStatus; // percents - int iSize=m_files.GetSize()*m_ucCopies; - int iIndex=m_nCurrentIndex+m_ucCurrentCopy*m_files.GetSize(); + size_t stSize = m_files.GetSize() * m_ucCopies; + size_t stIndex = m_stCurrentIndex + m_ucCurrentCopy * m_files.GetSize(); if (m_nAll != 0 && !((m_nStatus & ST_SPECIAL_MASK) & ST_IGNORE_CONTENT)) pData->m_nPercent=static_cast( (static_cast(m_nProcessed)*100.0)/static_cast(m_nAll) ); else - if (iSize != 0) - pData->m_nPercent=static_cast( static_cast(iIndex)*100.0/static_cast(iSize) ); + if (stSize != 0) + pData->m_nPercent=static_cast( static_cast(stIndex)*100.0/static_cast(stSize) ); else pData->m_nPercent=0; @@ -780,8 +788,8 @@ void CTask::GetSnapshot(TASK_DISPLAY_DATA *pData) { m_cs.Lock(); - if (m_nCurrentIndex >= 0 && m_nCurrentIndex < m_files.GetSize()) - pData->m_fi=m_files.GetAt(m_nCurrentIndex); + if (m_stCurrentIndex >= 0 && m_stCurrentIndex < m_files.GetSize()) + pData->m_fi=m_files.GetAt(m_stCurrentIndex); else { if (m_files.GetSize() > 0) @@ -812,25 +820,25 @@ pData->m_dwOsErrorCode=m_lOsError; pData->m_strErrorDesc=m_strErrorDesc; pData->m_uiStatus=m_nStatus; - pData->m_iIndex=m_nCurrentIndex+m_ucCurrentCopy*m_files.GetSize(); + pData->m_stIndex=m_stCurrentIndex+m_ucCurrentCopy*m_files.GetSize(); pData->m_ullProcessedSize=m_nProcessed; - pData->m_iSize=m_files.GetSize()*m_ucCopies; + pData->m_stSize=m_files.GetSize()*m_ucCopies; pData->m_ullSizeAll=m_nAll; pData->m_ucCurrentCopy=static_cast(m_ucCurrentCopy+1); // visual aspect pData->m_ucCopies=m_ucCopies; pData->m_pstrUniqueName=&m_strUniqueName; - if (m_files.GetSize() > 0 && m_nCurrentIndex != -1) - pData->m_iCurrentBufferIndex=m_bsSizes.m_bOnlyDefault ? 0 : m_files.GetAt((m_nCurrentIndex < m_files.GetSize()) ? m_nCurrentIndex : 0).GetBufferIndex(); + if (m_files.GetSize() > 0 && m_stCurrentIndex != -1) + pData->m_iCurrentBufferIndex=m_bsSizes.m_bOnlyDefault ? 0 : m_files.GetAt((m_stCurrentIndex < m_files.GetSize()) ? m_stCurrentIndex : 0).GetBufferIndex(); else pData->m_iCurrentBufferIndex=0; // percents if (m_nAll != 0 && !((m_nStatus & ST_SPECIAL_MASK) & ST_IGNORE_CONTENT)) pData->m_nPercent=static_cast( (static_cast(m_nProcessed)*100.0)/static_cast(m_nAll) ); else - if (pData->m_iSize != 0) - pData->m_nPercent=static_cast( static_cast(pData->m_iIndex)*100.0/static_cast(pData->m_iSize) ); + if (pData->m_stSize != 0) + pData->m_nPercent=static_cast( static_cast(pData->m_stIndex)*100.0/static_cast(pData->m_stSize) ); else pData->m_nPercent=0; @@ -1045,21 +1053,21 @@ return ucCopy; } -void CTask::SetLastProcessedIndex(int iIndex) +void CTask::SetLastProcessedIndex(size_t stIndex) { m_cs.Lock(); - m_iLastProcessedIndex=iIndex; + m_stLastProcessedIndex = stIndex; m_cs.Unlock(); } -int CTask::GetLastProcessedIndex() +size_t CTask::GetLastProcessedIndex() { - int iIndex; + size_t stIndex = 0; m_cs.Lock(); - iIndex=m_iLastProcessedIndex; + stIndex = m_stLastProcessedIndex; m_cs.Unlock(); - return iIndex; + return stIndex; } bool CTask::GetRequiredFreeSpace(ull_t *pullNeeded, ull_t *pullAvailable) @@ -1168,55 +1176,43 @@ return pTask; } -int CTaskArray::GetSize( ) +size_t CTaskArray::GetSize() { m_cs.Lock(); - int nSize=m_nSize; + size_t stSize = m_nSize; m_cs.Unlock(); - return nSize; + return stSize; } -int CTaskArray::GetUpperBound( ) +size_t CTaskArray::GetUpperBound( ) { m_cs.Lock(); - int upper=m_nSize; + size_t stUpper = m_nSize; m_cs.Unlock(); - return upper-1; + return stUpper - 1; } -void CTaskArray::SetSize( int nNewSize, int nGrowBy ) +void CTaskArray::SetSize(size_t nNewSize, int nGrowBy) { m_cs.Lock(); (static_cast*>(this))->SetSize(nNewSize, nGrowBy); m_cs.Unlock(); } -CTask* CTaskArray::GetAt( int nIndex ) +CTask* CTaskArray::GetAt(size_t nIndex) { - ASSERT(nIndex >= 0 && nIndex < m_nSize); + ASSERT(nIndex >= 0 && nIndex < (size_t)m_nSize); m_cs.Lock(); - CTask* pTask=m_pData[nIndex]; + CTask* pTask = m_pData[nIndex]; m_cs.Unlock(); return pTask; } -/* -void CTaskArray::SetAt( int nIndex, CTask* newElement ) +size_t CTaskArray::Add(CTask* newElement) { -m_cs.Lock(); -ASSERT(nIndex >= 0 && nIndex < m_nSize); -m_uhRange-=m_pData[nIndex]->GetAllSize(); // subtract old element -m_pData[nIndex]=newElement; -m_uhRange+=m_pData[nIndex]->GetAllSize(); // add new -m_cs.Unlock(); -} -*/ - -int CTaskArray::Add( CTask* newElement ) -{ if(!newElement) THROW(_t("Invalid argument"), 0, 0, 0); m_cs.Lock(); @@ -1225,30 +1221,30 @@ m_uhRange+=newElement->GetAllSize(); m_uhPosition+=newElement->GetProcessedSize(); - int pos=(static_cast*>(this))->Add(newElement); + size_t pos = (static_cast*>(this))->Add(newElement); m_cs.Unlock(); return pos; } -void CTaskArray::RemoveAt(int nIndex, int nCount) +void CTaskArray::RemoveAt(size_t stIndex, size_t stCount) { m_cs.Lock(); - for (int i=nIndex;iKillThread(); - m_uhRange-=pTask->GetAllSize(); - m_uhPosition-=pTask->GetProcessedSize(); + m_uhRange -= pTask->GetAllSize(); + m_uhPosition -= pTask->GetProcessedSize(); delete pTask; } // remove elements from array - (static_cast*>(this))->RemoveAt(nIndex, nCount); + (static_cast*>(this))->RemoveAt(stIndex, stCount); m_cs.Unlock(); } @@ -1285,11 +1281,11 @@ void CTaskArray::RemoveAllFinished() { m_cs.Lock(); - int i=GetSize(); + size_t i = GetSize(); - while (i) + while(i--) { - CTask* pTask=GetAt(i-1); + CTask* pTask = GetAt(i); // delete only when the thread is finished if ( (pTask->GetStatus(ST_STEP_MASK) == ST_FINISHED || pTask->GetStatus(ST_STEP_MASK) == ST_CANCELLED) @@ -1303,10 +1299,8 @@ delete pTask; - static_cast*>(this)->RemoveAt(i-1); + static_cast*>(this)->RemoveAt(i); } - - --i; } m_cs.Unlock(); @@ -1366,9 +1360,9 @@ CString strPath; BOOL bWorking=finder.FindFile(CString(m_strTasksDir.c_str())+_T("*.atd")); - while ( bWorking ) + while(bWorking) { - bWorking=finder.FindNextFile(); + bWorking = finder.FindNextFile(); // load data pTask = CreateTask(); @@ -1377,31 +1371,20 @@ { strPath = finder.GetFilePath(); - // load data file - icpf::archive ar; - ar.open(strPath, FA_READ); - ar.datablock_begin(); - pTask->Load(ar, true); - ar.datablock_end(); - ar.close(); + pTask->Load(strPath, true); - // load progress file - strPath=strPath.Left(strPath.GetLength()-4); - strPath+=_T(".atp"); - icpf::archive ar2; - ar2.open(strPath, FA_READ); - ar2.datablock_begin(); - pTask->Load(ar2, false); - ar2.datablock_end(); - ar2.close(); + strPath = strPath.Left(strPath.GetLength() - 4); + strPath += _T(".atp"); + pTask->Load(strPath, false); + // add read task to array Add(pTask); } - catch(icpf::exception&) + catch(std::exception& e) { CString strFmt; - strFmt.Format(_T("Cannot load task data: %s"), strPath); + strFmt.Format(_T("Cannot load task data: %s (reason: %S)"), strPath, e.what()); LOG_ERROR(strFmt); delete pTask; } @@ -1588,7 +1571,7 @@ pTask->FilesRemoveAll(); // enter some data to m_files - int nSize=pTask->GetClipboardDataSize(); // size of m_clipboard + size_t stSize = pTask->GetClipboardDataSize(); // size of m_clipboard const CFiltersArray* pFilters=pTask->GetFilters(); int iDestDrvNumber=pTask->GetDestDriveNumber(); bool bIgnoreDirs=(pTask->GetStatus(ST_SPECIAL_MASK) & ST_IGNORE_DIRS) != 0; @@ -1602,7 +1585,7 @@ bool bRetry = true; bool bSkipInputPath = false; - for (int i=0;iGetCurrentIndex(); - while(iIndex < pTask->FilesGetSize()) + size_t stIndex = pTask->GetCurrentIndex(); + while(stIndex < pTask->FilesGetSize()) { // set index in pTask to currently deleted element - pTask->SetCurrentIndex(iIndex); + pTask->SetCurrentIndex(stIndex); // check for kill flag if (pTask->GetKillFlag()) @@ -1772,10 +1755,10 @@ } // current processed element - fi=pTask->FilesGetAt(pTask->FilesGetSize()-iIndex-1); + fi=pTask->FilesGetAt(pTask->FilesGetSize()-stIndex-1); if(!(fi.GetFlags() & FIF_PROCESSED)) { - ++iIndex; + ++stIndex; continue; } @@ -1814,7 +1797,7 @@ throw new CProcessingException(E_CANCEL, pTask); break; case CFeedbackHandler::eResult_Retry: - continue; // no iIndex bump, since we are trying again + continue; // no stIndex bump, since we are trying again break; case CFeedbackHandler::eResult_Pause: throw new CProcessingException(E_PAUSE, pTask); @@ -1827,7 +1810,7 @@ } } - ++iIndex; + ++stIndex; }//while // change status to finished @@ -1851,12 +1834,12 @@ // Data regarding dest file CFileInfo fiDest; - bool bExist=fiDest.Create(pData->strDstFile, -1); + bool bExist=fiDest.Create(pData->strDstFile, std::numeric_limits::max()); chcore::IFeedbackHandler* piFeedbackHandler = pData->pTask->GetFeedbackHandler(); BOOST_ASSERT(piFeedbackHandler); - pData->pTask->SetLastProcessedIndex(-1); + pData->pTask->SetLastProcessedIndex(std::numeric_limits::max()); // if dest file size >0 - we can do somethng more than usual if(bExist) @@ -1923,7 +1906,7 @@ // refresh data about file if (!bFirstPass) - bExist=fiDest.Create(pData->strDstFile, -1); + bExist=fiDest.Create(pData->strDstFile, std::numeric_limits::max()); // open src l_openingsrc: @@ -2313,7 +2296,7 @@ DWORD dwLastError; // begin at index which wasn't processed previously - int nSize=pTask->FilesGetSize(); + size_t stSize = pTask->FilesGetSize(); int iCopiesCount=pTask->GetCopies(); bool bIgnoreFolders=(pTask->GetStatus(ST_SPECIAL_MASK) & ST_IGNORE_DIRS) != 0; bool bForceDirectories=(pTask->GetStatus(ST_SPECIAL_MASK) & ST_FORCE_DIRS) != 0; @@ -2330,7 +2313,7 @@ fmt.SetParam(_t("%twosize"), pbs->m_uiTwoDisksSize); fmt.SetParam(_t("%cdsize"), pbs->m_uiCDSize); fmt.SetParam(_t("%lansize"), pbs->m_uiLANSize); - fmt.SetParam(_t("%filecount"), nSize); + fmt.SetParam(_t("%filecount"), stSize); fmt.SetParam(_t("%copycount"), iCopiesCount); fmt.SetParam(_t("%ignorefolders"), bIgnoreFolders); fmt.SetParam(_t("%dstpath"), dpDestPath.GetPath()); @@ -2342,7 +2325,7 @@ for (unsigned char j=pTask->GetCurrentCopy();jSetCurrentCopy(j); - for (int i=pTask->GetCurrentIndex();iGetCurrentIndex(); i < stSize; i++) { // should we kill ? if (pTask->GetKillFlag()) @@ -2352,7 +2335,7 @@ throw new CProcessingException(E_KILL_REQUEST, pTask); } - // update m_nCurrentIndex, getting current CFileInfo + // update m_stCurrentIndex, getting current CFileInfo pTask->SetCurrentIndex(i); CFileInfo& fi=pTask->FilesGetAtCurrentIndex(); @@ -2490,7 +2473,7 @@ pTask->SetStatus(ST_FINISHED, ST_STEP_MASK); // to look better - increase current index by 1 - pTask->SetCurrentIndex(nSize); + pTask->SetCurrentIndex(stSize); } // log pTask->m_log.logi(_T("Finished processing in ProcessFiles")); Index: src/ch/task.h =================================================================== diff -u -N -r8cb15f097b81ca387f3ae122dd355f3c397b7842 -r5057e08b0cc064972abeb94a488e5f12d9db14a0 --- src/ch/task.h (.../task.h) (revision 8cb15f097b81ca387f3ae122dd355f3c397b7842) +++ src/ch/task.h (.../task.h) (revision 5057e08b0cc064972abeb94a488e5f12d9db14a0) @@ -90,8 +90,8 @@ { CFileInfo m_fi; // fi at CurrIndex int m_iCurrentBufferIndex; - int m_iIndex; - int m_iSize; + size_t m_stIndex; + size_t m_stSize; CDestPath* m_pdpDestPath; CFiltersArray* m_pafFilters; @@ -144,24 +144,24 @@ ~CTask(); // m_clipboard - void AddClipboardData(CClipboardEntry* pEntry); - CClipboardEntry* GetClipboardData(int nIndex); - int GetClipboardDataSize(); + void AddClipboardData(const CClipboardEntryPtr& spEntry); + CClipboardEntryPtr GetClipboardData(size_t stIndex); + size_t GetClipboardDataSize(); int ReplaceClipboardStrings(CString strOld, CString strNew); // m_files - int FilesAddDir(const CString strDirName, const CFiltersArray* pFilters, int iSrcIndex, + int FilesAddDir(const CString strDirName, const CFiltersArray* pFilters, size_t stSrcIndex, const bool bRecurse, const bool bIncludeDirs); void FilesAdd(CFileInfo fi); - CFileInfo FilesGetAt(int nIndex); + CFileInfo FilesGetAt(size_t stIndex); CFileInfo& FilesGetAtCurrentIndex(); void FilesRemoveAll(); size_t FilesGetSize(); - // m_nCurrentIndex + // m_stCurrentIndex void IncreaseCurrentIndex(); - int GetCurrentIndex(); - void SetCurrentIndex(int nIndex); + size_t GetCurrentIndex(); + void SetCurrentIndex(size_t stIndex); // m_strDestPath void SetDestPath(LPCTSTR lpszPath); @@ -214,7 +214,7 @@ // m_strUniqueName CString GetUniqueName(); - void Load(icpf::archive& ar, bool bData); + void Load(const CString& strPath, bool bData); void Store(bool bData); void BeginProcessing(); @@ -250,8 +250,8 @@ CClipboardArray* GetClipboard() { return &m_clipboard; }; - void SetLastProcessedIndex(int iIndex); - int GetLastProcessedIndex(); + void SetLastProcessedIndex(size_t stIndex); + size_t GetLastProcessedIndex(); // CString GetLogName(); @@ -298,8 +298,8 @@ protected: CClipboardArray m_clipboard; CFileInfoArray m_files; - volatile int m_nCurrentIndex; - int m_iLastProcessedIndex; + volatile size_t m_stCurrentIndex; + size_t m_stLastProcessedIndex; CDestPath m_dpDestPath; @@ -375,15 +375,14 @@ CTask* CreateTask(); - int GetSize( ); - int GetUpperBound( ); - void SetSize( int nNewSize, int nGrowBy = -1 ); + size_t GetSize( ); + size_t GetUpperBound( ); + void SetSize(size_t stNewSize, int nGrowBy = -1); - CTask* GetAt( int nIndex ); - // void SetAt( int nIndex, CTask* newElement ); - int Add( CTask* newElement ); + CTask* GetAt(size_t stIndex); + size_t Add(CTask* newElement); - void RemoveAt( int nIndex, int nCount = 1 ); + void RemoveAt(size_t stIndex, size_t stCount = 1); void RemoveAll(); void RemoveAllFinished(); void RemoveFinished(CTask** pSelTask);