Index: src/ch/AppHelper.cpp =================================================================== diff -u -r50830b27409540a4b2c97b40cfbf86b78dd02327 -rf6c4389122d92e5f84a509e9be0facebac429151 --- src/ch/AppHelper.cpp (.../AppHelper.cpp) (revision 50830b27409540a4b2c97b40cfbf86b78dd02327) +++ src/ch/AppHelper.cpp (.../AppHelper.cpp) (revision f6c4389122d92e5f84a509e9be0facebac429151) @@ -225,6 +225,11 @@ if(!CreateDirectory(rStrPath, NULL) && GetLastError() != ERROR_ALREADY_EXISTS) return false; + // create directory for tasks + rStrPath += _T("\\Tasks"); + if(!CreateDirectory(rStrPath, NULL) && GetLastError() != ERROR_ALREADY_EXISTS) + return false; + return true; } Index: src/ch/CfgProperties.cpp =================================================================== diff -u -rb6b8ac5b0a1ab85b4ac788e5429be860d2f20bd5 -rf6c4389122d92e5f84a509e9be0facebac429151 --- src/ch/CfgProperties.cpp (.../CfgProperties.cpp) (revision b6b8ac5b0a1ab85b4ac788e5429be860d2f20bd5) +++ src/ch/CfgProperties.cpp (.../CfgProperties.cpp) (revision f6c4389122d92e5f84a509e9be0facebac429151) @@ -38,7 +38,7 @@ pManager->register_bool(_t("Program/Force shutdown"), false); pManager->register_signed_num(_t("Program/Autosave interval"), 30*llSecond, 0, 24*llHour); pManager->register_signed_num(_t("Program/Process priority class"), NORMAL_PRIORITY_CLASS, 0, 0xffffffff); - pManager->register_string(_t("Program/Autosave directory"), _t("\\"), icpf::property::flag_path); +// pManager->register_string(_t("Program/Autosave directory"), _t("\\"), icpf::property::flag_path); pManager->register_string(_t("Program/Language"), _t("\\Langs\\English.lng")); pManager->register_signed_num(_t("Status dialog/Status refresh interval"), 1000, 0, 24*llHour); Index: src/ch/CfgProperties.h =================================================================== diff -u -rb6b8ac5b0a1ab85b4ac788e5429be860d2f20bd5 -rf6c4389122d92e5f84a509e9be0facebac429151 --- src/ch/CfgProperties.h (.../CfgProperties.h) (revision b6b8ac5b0a1ab85b4ac788e5429be860d2f20bd5) +++ src/ch/CfgProperties.h (.../CfgProperties.h) (revision f6c4389122d92e5f84a509e9be0facebac429151) @@ -24,85 +24,88 @@ #include "../libicpf/cfg.h" // properties definitions -#define PP_PCLIPBOARDMONITORING 0 -#define PP_PMONITORSCANINTERVAL 1 -#define PP_PRELOADAFTERRESTART 2 -#define PP_PSHUTDOWNAFTREFINISHED 3 -#define PP_PTIMEBEFORESHUTDOWN 4 -#define PP_PFORCESHUTDOWN 5 -#define PP_PAUTOSAVEINTERVAL 6 -#define PP_PPROCESSPRIORITYCLASS 7 -#define PP_PAUTOSAVEDIRECTORY 8 -#define PP_PLANGUAGE 9 +enum CHProperties +{ + PP_PCLIPBOARDMONITORING = 0, + PP_PMONITORSCANINTERVAL, + PP_PRELOADAFTERRESTART, + PP_PSHUTDOWNAFTREFINISHED, + PP_PTIMEBEFORESHUTDOWN, + PP_PFORCESHUTDOWN, + PP_PAUTOSAVEINTERVAL, + PP_PPROCESSPRIORITYCLASS, +// PP_PAUTOSAVEDIRECTORY, + PP_PLANGUAGE, -#define PP_STATUSREFRESHINTERVAL 10 -#define PP_STATUSSHOWDETAILS 11 -#define PP_STATUSAUTOREMOVEFINISHED 12 + PP_STATUSREFRESHINTERVAL, + PP_STATUSSHOWDETAILS, + PP_STATUSAUTOREMOVEFINISHED, -#define PP_FDWIDTH 13 -#define PP_FDHEIGHT 14 -#define PP_FDSHORTCUTLISTSTYLE 15 -#define PP_FDEXTENDEDVIEW 16 -#define PP_FDIGNORESHELLDIALOGS 17 + PP_FDWIDTH, + PP_FDHEIGHT, + PP_FDSHORTCUTLISTSTYLE, + PP_FDEXTENDEDVIEW, + PP_FDIGNORESHELLDIALOGS, -#define PP_MVSHOWFILENAMES 18 -#define PP_MVSHOWSINGLETASKS 19 -#define PP_MVREFRESHINTERVAL 20 -#define PP_MVAUTOSHOWWHENRUN 21 -#define PP_MVAUTOHIDEWHENEMPTY 22 -#define PP_MVUSESMOOTHPROGRESS 23 + PP_MVSHOWFILENAMES, + PP_MVSHOWSINGLETASKS, + PP_MVREFRESHINTERVAL, + PP_MVAUTOSHOWWHENRUN, + PP_MVAUTOHIDEWHENEMPTY, + PP_MVUSESMOOTHPROGRESS, -#define PP_CMUSEAUTOCOMPLETEFILES 24 -#define PP_CMSETDESTATTRIBUTES 25 -#define PP_CMSETDESTDATE 26 -#define PP_CMPROTECTROFILES 27 -#define PP_CMLIMITMAXOPERATIONS 28 -#define PP_CMREADSIZEBEFOREBLOCKING 29 -#define PP_CMSHOWVISUALFEEDBACK 30 -#define PP_CMUSETIMEDFEEDBACK 31 -#define PP_CMFEEDBACKTIME 32 -#define PP_CMAUTORETRYONERROR 33 -#define PP_CMAUTORETRYINTERVAL 34 -#define PP_CMDEFAULTPRIORITY 35 -#define PP_CMDISABLEPRIORITYBOOST 36 -#define PP_CMDELETEAFTERFINISHED 37 -#define PP_CMCREATELOG 38 + PP_CMUSEAUTOCOMPLETEFILES, + PP_CMSETDESTATTRIBUTES, + PP_CMSETDESTDATE, + PP_CMPROTECTROFILES, + PP_CMLIMITMAXOPERATIONS, + PP_CMREADSIZEBEFOREBLOCKING, + PP_CMSHOWVISUALFEEDBACK, + PP_CMUSETIMEDFEEDBACK, + PP_CMFEEDBACKTIME, + PP_CMAUTORETRYONERROR, + PP_CMAUTORETRYINTERVAL, + PP_CMDEFAULTPRIORITY, + PP_CMDISABLEPRIORITYBOOST, + PP_CMDELETEAFTERFINISHED, + PP_CMCREATELOG, -#define PP_SHSHOWCOPY 39 -#define PP_SHSHOWMOVE 40 -#define PP_SHSHOWCOPYMOVE 41 -#define PP_SHSHOWPASTE 42 -#define PP_SHSHOWPASTESPECIAL 43 -#define PP_SHSHOWCOPYTO 44 -#define PP_SHSHOWMOVETO 45 -#define PP_SHSHOWCOPYMOVETO 46 -#define PP_SHSHOWFREESPACE 47 -#define PP_SHSHOWSHELLICONS 48 -#define PP_SHUSEDRAGDROP 49 -#define PP_SHDEFAULTACTION 50 + PP_SHSHOWCOPY, + PP_SHSHOWMOVE, + PP_SHSHOWCOPYMOVE, + PP_SHSHOWPASTE, + PP_SHSHOWPASTESPECIAL, + PP_SHSHOWCOPYTO, + PP_SHSHOWMOVETO, + PP_SHSHOWCOPYMOVETO, + PP_SHSHOWFREESPACE, + PP_SHSHOWSHELLICONS, + PP_SHUSEDRAGDROP, + PP_SHDEFAULTACTION, -#define PP_BFUSEONLYDEFAULT 51 -#define PP_BFDEFAULT 52 -#define PP_BFONEDISK 53 -#define PP_BFTWODISKS 54 -#define PP_BFCD 55 -#define PP_BFLAN 56 -#define PP_BFUSENOBUFFERING 57 -#define PP_BFBOUNDARYLIMIT 58 + PP_BFUSEONLYDEFAULT, + PP_BFDEFAULT, + PP_BFONEDISK, + PP_BFTWODISKS, + PP_BFCD, + PP_BFLAN, + PP_BFUSENOBUFFERING, + PP_BFBOUNDARYLIMIT, -#define PP_LOGPATH 59 -#define PP_LOGENABLELOGGING 60 -#define PP_LOGLIMITATION 61 -#define PP_LOGMAXLIMIT 62 -#define PP_LOGPRECISELIMITING 63 -#define PP_LOGTRUNCBUFFERSIZE 64 + PP_LOGPATH, + PP_LOGENABLELOGGING, + PP_LOGLIMITATION, + PP_LOGMAXLIMIT, + PP_LOGPRECISELIMITING, + PP_LOGTRUNCBUFFERSIZE, -#define PP_SNDPLAYSOUNDS 65 -#define PP_SNDERRORSOUNDPATH 66 -#define PP_SNDFINISHEDSOUNDPATH 67 + PP_SNDPLAYSOUNDS, + PP_SNDERRORSOUNDPATH, + PP_SNDFINISHEDSOUNDPATH, -#define PP_SHORTCUTS 68 -#define PP_RECENTPATHS 69 + PP_SHORTCUTS, + PP_RECENTPATHS +}; // register function bool RegisterProperties(icpf::config* pManager); Index: src/ch/MainWnd.cpp =================================================================== diff -u -r6ae1d95bf7dd071fd2b65b8f7aabca1c887bdff8 -rf6c4389122d92e5f84a509e9be0facebac429151 --- src/ch/MainWnd.cpp (.../MainWnd.cpp) (revision 6ae1d95bf7dd071fd2b65b8f7aabca1c887bdff8) +++ src/ch/MainWnd.cpp (.../MainWnd.cpp) (revision f6c4389122d92e5f84a509e9be0facebac429151) @@ -348,11 +348,8 @@ pTask->SetStatus(ST_COPYING, ST_STEP_MASK); // save task status - TCHAR szPath[_MAX_PATH]; - GetConfig()->get_string(PP_PAUTOSAVEDIRECTORY, szPath, _MAX_PATH); - GetApp()->ExpandPath(szPath); - pTask->Store(szPath, true); - pTask->Store(szPath, false); + pTask->Store(true); + pTask->Store(false); // log pTask->m_log.logi(GetResManager()->LoadString(IDS_OTFSEARCHINGFINISHED_STRING)); @@ -1119,12 +1116,14 @@ { TRACE("\n\nENTERING ThrdProc (new task started)...\n"); CTask* pTask=static_cast(pParam); + TCHAR szPath[_MAX_PATH]; - GetConfig()->get_string(PP_PAUTOSAVEDIRECTORY, szPath, _MAX_PATH); - GetApp()->ExpandPath(szPath); - _tcscat(szPath, pTask->GetUniqueName()+_T(".log")); - pTask->m_log.init(szPath, 262144, icpf::log_file::level_debug, false, false); + tstring_t strPath = pTask->GetTaskPath(); + strPath += pTask->GetUniqueName()+_T(".log"); + + pTask->m_log.init(strPath.c_str(), 262144, icpf::log_file::level_debug, false, false); + // set thread boost HANDLE hThread=GetCurrentThread(); ::SetThreadPriorityBoost(hThread, GetConfig()->get_bool(PP_CMDISABLEPRIORITYBOOST)); @@ -1243,9 +1242,7 @@ pTask->UpdateTime(); // save progress before killed - GetConfig()->get_string(PP_PAUTOSAVEDIRECTORY, szPath, _MAX_PATH); - GetApp()->ExpandPath(szPath); - pTask->Store(szPath, false); + pTask->Store(false); // we are ending pTask->DecreaseOperationsPending(); @@ -1467,11 +1464,8 @@ pTask->GetClipboard()->GetAt(i)->CalcBufferIndex(pTask->GetDestPath()); // write pTask to a file - TCHAR szPath[_MAX_PATH]; - GetConfig()->get_string(PP_PAUTOSAVEDIRECTORY, szPath, _MAX_PATH); - GetApp()->ExpandPath(szPath); - pTask->Store(szPath, true); - pTask->Store(szPath, false); + pTask->Store(true); + pTask->Store(false); // add task to a list of tasks and start pData->m_pTasks->Add(pTask); @@ -1582,10 +1576,11 @@ m_tasks.Create(&ThrdProc); // load last state - TCHAR szPath[_MAX_PATH]; - GetConfig()->get_string(PP_PAUTOSAVEDIRECTORY, szPath, _MAX_PATH); - GetApp()->ExpandPath(szPath); - m_tasks.LoadDataProgress(szPath); + CString strPath; + GetApp()->GetProgramDataPath(strPath); + strPath += _T("\\tasks"); + m_tasks.SetTasksDir(strPath); + m_tasks.LoadDataProgress(); m_tasks.TasksRetryProcessing(); // start clipboard monitoring @@ -1726,10 +1721,7 @@ case 1023: // autosave timer KillTimer(1023); - TCHAR szPath[_MAX_PATH]; - GetConfig()->get_string(PP_PAUTOSAVEDIRECTORY, szPath, _MAX_PATH); - GetApp()->ExpandPath(szPath); - m_tasks.SaveProgress(szPath); + m_tasks.SaveProgress(); SetTimer(1023, (UINT)GetConfig()->get_signed_num(PP_PAUTOSAVEINTERVAL), NULL); break; case 7834: @@ -1925,15 +1917,13 @@ pTask->SetFilters(&ffFilters); pTask->SetCopies(ucCopies); + m_tasks.Add(pTask); + // save state of a task - TCHAR szPath[_MAX_PATH]; - GetConfig()->get_string(PP_PAUTOSAVEDIRECTORY, szPath, _MAX_PATH); - GetApp()->ExpandPath(szPath); - pTask->Store(szPath, true); - pTask->Store(szPath, false); + pTask->Store(true); + pTask->Store(false); // add to task list and start processing - m_tasks.Add(pTask); pTask->BeginProcessing(); return CWnd::OnCopyData(pWnd, pCopyDataStruct); @@ -2012,15 +2002,13 @@ pTask->SetPriority(dlg.m_ccData.m_iPriority); pTask->SetFilters(&dlg.m_ccData.m_afFilters); + m_tasks.Add(pTask); + // save - TCHAR szPath[_MAX_PATH]; - GetConfig()->get_string(PP_PAUTOSAVEDIRECTORY, szPath, _MAX_PATH); - GetApp()->ExpandPath(szPath); - pTask->Store(szPath, true); - pTask->Store(szPath, false); + pTask->Store(true); + pTask->Store(false); // store and start - m_tasks.Add(pTask); pTask->BeginProcessing(); } } @@ -2310,10 +2298,7 @@ } // save - TCHAR szPath[_MAX_PATH]; - GetConfig()->get_string(PP_PAUTOSAVEDIRECTORY, szPath, _MAX_PATH); - GetApp()->ExpandPath(szPath); - m_tasks.SaveProgress(szPath); + m_tasks.SaveProgress(); // delete all tasks int iSize=m_tasks.GetSize(); Index: src/ch/OptionsDlg.cpp =================================================================== diff -u -rb6b8ac5b0a1ab85b4ac788e5429be860d2f20bd5 -rf6c4389122d92e5f84a509e9be0facebac429151 --- src/ch/OptionsDlg.cpp (.../OptionsDlg.cpp) (revision b6b8ac5b0a1ab85b4ac788e5429be860d2f20bd5) +++ src/ch/OptionsDlg.cpp (.../OptionsDlg.cpp) (revision f6c4389122d92e5f84a509e9be0facebac429151) @@ -235,10 +235,6 @@ PROP_COMBO(IDS_FORCESHUTDOWN_STRING, IDS_FORCESHUTDOWNVALUES_STRING, GetConfig()->get_bool(PP_PFORCESHUTDOWN)) PROP_UINT(IDS_AUTOSAVEINTERVAL_STRING, GetConfig()->get_signed_num(PP_PAUTOSAVEINTERVAL)) PROP_COMBO(IDS_CFGPRIORITYCLASS_STRING, IDS_CFGPRIORITYCLASSITEMS_STRING, PriorityClassToIndex(GetConfig()->get_signed_num(PP_PPROCESSPRIORITYCLASS))) - - GetConfig()->get_string(PP_PAUTOSAVEDIRECTORY, strPath.GetBuffer(_MAX_PATH), _MAX_PATH); - strPath.ReleaseBuffer(); - TRACE(_t("Autosavedir=%s\n"), strPath); PROP_DIR(IDS_TEMPFOLDER_STRING, IDS_TEMPFOLDERCHOOSE_STRING, strPath) // lang @@ -362,7 +358,6 @@ pConfig->set_bool(PP_PFORCESHUTDOWN, GetBoolProp(iPosition++)); pConfig->set_signed_num(PP_PAUTOSAVEINTERVAL, GetUintProp(iPosition++)); pConfig->set_signed_num(PP_PPROCESSPRIORITYCLASS, IndexToPriorityClass(GetIndexProp(iPosition++))); - pConfig->set_string(PP_PAUTOSAVEDIRECTORY, GetStringProp(iPosition++)); // language PCTSTR pszSrc=m_vld.at(GetIndexProp(iPosition++)).GetFilename(true); if (_tcsnicmp(pszSrc, GetApp()->GetProgramPath(), _tcslen(GetApp()->GetProgramPath())) == 0) Index: src/ch/StatusDlg.cpp =================================================================== diff -u -r336bb030d9b4bff561ff100563725213ed6703c9 -rf6c4389122d92e5f84a509e9be0facebac429151 --- src/ch/StatusDlg.cpp (.../StatusDlg.cpp) (revision 336bb030d9b4bff561ff100563725213ed6703c9) +++ src/ch/StatusDlg.cpp (.../StatusDlg.cpp) (revision f6c4389122d92e5f84a509e9be0facebac429151) @@ -334,9 +334,7 @@ { GetDlgItem(IDC_DESTINATION_STATIC)->SetWindowText(td.m_pdpDestPath->GetPath()); GetDlgItem(IDC_PRIORITY_STATIC)->SetWindowText(GetResManager()->LoadString(IDS_PRIORITY0_STRING+PriorityToIndex(td.m_nPriority))); - GetConfig()->get_string(PP_PAUTOSAVEDIRECTORY, m_strTemp.GetBuffer(1024), 1024); - m_strTemp.ReleaseBuffer(); - GetDlgItem(IDC_ASSOCIATEDFILES__STATIC)->SetWindowText(m_strTemp+*td.m_pstrUniqueName+_T(".atd (.atp, .log)")); + GetDlgItem(IDC_ASSOCIATEDFILES__STATIC)->SetWindowText(*td.m_pstrUniqueName+_T(".atd (.atp, .log)")); } // refresh m_pLastSelected @@ -872,14 +870,11 @@ return; // call what's needed - TCHAR szExec[1024]; - GetConfig()->get_string(PP_PAUTOSAVEDIRECTORY, szExec, 1024); - GetApp()->ExpandPath(szExec); unsigned long lResult=(unsigned long)(ShellExecute(this->m_hWnd, _T("open"), _T("notepad.exe"), - CString(szExec)+pTask->GetUniqueName()+_T(".log"), szExec, SW_SHOWNORMAL)); + CString(pTask->GetTaskPath())+pTask->GetUniqueName()+_T(".log"), NULL, SW_SHOWNORMAL)); if (lResult < 32) { - CString str=CString(szExec)+pTask->GetUniqueName()+_T(".log"); + CString str=CString(pTask->GetTaskPath())+pTask->GetUniqueName()+_T(".log"); ictranslate::CFormat fmt(GetResManager()->LoadString(IDS_SHELLEXECUTEERROR_STRING)); fmt.SetParam(_t("%errno"), lResult); fmt.SetParam(_t("%path"), str); Index: src/ch/Stdafx.h =================================================================== diff -u -rd2b121c78f510b5384b8ef0ca80afbfd7f77fef7 -rf6c4389122d92e5f84a509e9be0facebac429151 --- src/ch/Stdafx.h (.../Stdafx.h) (revision d2b121c78f510b5384b8ef0ca80afbfd7f77fef7) +++ src/ch/Stdafx.h (.../Stdafx.h) (revision f6c4389122d92e5f84a509e9be0facebac429151) @@ -31,6 +31,7 @@ #pragma warning (disable: 4711) #include "debug.h" #include "../libictranslate/LanguageDialog.h" +#include #ifdef _UNICODE #if defined _M_IX86 Index: src/ch/Structs.cpp =================================================================== diff -u -r6ae1d95bf7dd071fd2b65b8f7aabca1c887bdff8 -rf6c4389122d92e5f84a509e9be0facebac429151 --- src/ch/Structs.cpp (.../Structs.cpp) (revision 6ae1d95bf7dd071fd2b65b8f7aabca1c887bdff8) +++ src/ch/Structs.cpp (.../Structs.cpp) (revision f6c4389122d92e5f84a509e9be0facebac429151) @@ -617,9 +617,15 @@ m_cs.Unlock(); } -void CTask::Store(LPCTSTR lpszDirectory, bool bData) +void CTask::Store(bool bData) { m_cs.Lock(); + BOOST_ASSERT(!m_strTaskBasePath.empty()); + if(m_strTaskBasePath.empty()) + { + m_cs.Unlock(); + THROW(_t("Missing task path."), 0, 0, 0); + } if (!bData && m_bSaved) { m_cs.Unlock(); @@ -636,7 +642,7 @@ try { - CString strPath = lpszDirectory+GetUniqueName()+( (bData) ? _T(".atd") : _T(".atp") ); + 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(); @@ -1126,6 +1132,23 @@ return (*pi64Needed <= *pi64Available); } +void CTask::SetTaskPath(const tchar_t* pszDir) +{ + m_cs.Lock(); + m_strTaskBasePath = pszDir; + m_cs.Unlock(); +} + +const tchar_t* CTask::GetTaskPath() const +{ + const tchar_t* pszText = NULL; + m_cs.Lock(); + pszText = m_strTaskBasePath.c_str(); + m_cs.Unlock(); + + return pszText; +} + void CTask::SetForceFlag(bool bFlag) { m_cs.Lock(); @@ -1150,12 +1173,14 @@ return m_bContinue; } +/* CString CTask::GetLogName() { TCHAR szPath[_MAX_PATH]; GetConfig()->get_string(PP_PAUTOSAVEDIRECTORY, szPath, _MAX_PATH); return GetApp()->ExpandPath(szPath)+GetUniqueName()+_T(".log"); } +*/ //////////////////////////////////////////////////////////////////////////////// // CTaskArray members @@ -1208,6 +1233,7 @@ return pTask; } +/* void CTaskArray::SetAt( int nIndex, CTask* newElement ) { m_cs.Lock(); @@ -1217,10 +1243,16 @@ 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(); + // here we know load succeeded + newElement->SetTaskPath(m_strTasksDir.c_str()); + m_uhRange+=newElement->GetAllSize(); m_uhPosition+=newElement->GetProcessedSize(); int pos=(static_cast*>(this))->Add(newElement); @@ -1285,9 +1317,6 @@ m_cs.Lock(); int i=GetSize(); - TCHAR szPath[_MAX_PATH]; - GetConfig()->get_string(PP_PAUTOSAVEDIRECTORY, szPath, _MAX_PATH); - GetApp()->ExpandPath(szPath); while (i) { CTask* pTask=GetAt(i-1); @@ -1300,7 +1329,7 @@ m_uhPosition-=pTask->GetProcessedSize(); // delete associated files - pTask->DeleteProgress(szPath); + pTask->DeleteProgress(m_strTasksDir.c_str()); delete pTask; @@ -1316,9 +1345,6 @@ void CTaskArray::RemoveFinished(CTask** pSelTask) { m_cs.Lock(); - TCHAR szPath[_MAX_PATH]; - GetConfig()->get_string(PP_PAUTOSAVEDIRECTORY, szPath, _MAX_PATH); - GetApp()->ExpandPath(szPath); for (int i=0;iGetProcessedSize(); // delete associated files - pTask->DeleteProgress(szPath); + pTask->DeleteProgress(m_strTasksDir.c_str()); // delete data delete pTask; @@ -1346,29 +1372,29 @@ m_cs.Unlock(); } -void CTaskArray::SaveData(LPCTSTR lpszDirectory) +void CTaskArray::SaveData() { m_cs.Lock(); for (int i=0;iStore(lpszDirectory, true); + m_pData[i]->Store(true); m_cs.Unlock(); } -void CTaskArray::SaveProgress(LPCTSTR lpszDirectory) +void CTaskArray::SaveProgress() { m_cs.Lock(); for (int i=0;iStore(lpszDirectory, false); + m_pData[i]->Store(false); m_cs.Unlock(); } -void CTaskArray::LoadDataProgress(LPCTSTR lpszDirectory) +void CTaskArray::LoadDataProgress() { m_cs.Lock(); CFileFind finder; CTask* pTask; - BOOL bWorking=finder.FindFile(CString(lpszDirectory)+_T("*.atd")); + BOOL bWorking=finder.FindFile(CString(m_strTasksDir.c_str())+_T("*.atd")); while ( bWorking ) { bWorking=finder.FindNextFile(); @@ -1552,7 +1578,6 @@ void CProcessingException::Cleanup() { - TCHAR szPath[_MAX_PATH]; switch (m_pTask->GetStatus(ST_STEP_MASK)) { case ST_NULL_STATUS: @@ -1561,10 +1586,8 @@ m_pTask->FilesRemoveAll(); // save state of a task - GetConfig()->get_string(PP_PAUTOSAVEDIRECTORY, szPath, _MAX_PATH); - GetApp()->ExpandPath(szPath); - m_pTask->Store(szPath, true); - m_pTask->Store(szPath, false); + m_pTask->Store(true); + m_pTask->Store(false); m_pTask->SetKilledFlag(); m_pTask->CleanupAfterKill(); @@ -1583,9 +1606,7 @@ break; } - GetConfig()->get_string(PP_PAUTOSAVEDIRECTORY, szPath, _MAX_PATH); - GetApp()->ExpandPath(szPath); - m_pTask->Store(szPath, false); + m_pTask->Store(false); m_pTask->SetKilledFlag(); m_pTask->CleanupAfterKill(); Index: src/ch/Structs.h =================================================================== diff -u -r6ae1d95bf7dd071fd2b65b8f7aabca1c887bdff8 -rf6c4389122d92e5f84a509e9be0facebac429151 --- src/ch/Structs.h (.../Structs.h) (revision 6ae1d95bf7dd071fd2b65b8f7aabca1c887bdff8) +++ src/ch/Structs.h (.../Structs.h) (revision f6c4389122d92e5f84a509e9be0facebac429151) @@ -212,7 +212,7 @@ CString GetUniqueName(); void Load(icpf::archive& ar, bool bData); - void Store(LPCTSTR lpszDirectory, bool bData); + void Store(bool bData); void BeginProcessing(); @@ -250,10 +250,13 @@ void SetLastProcessedIndex(int iIndex); int GetLastProcessedIndex(); - CString GetLogName(); +// CString GetLogName(); bool GetRequiredFreeSpace(__int64 *pi64Needed, __int64 *pi64Available); + void SetTaskPath(const tchar_t* pszDir); + const tchar_t* GetTaskPath() const; + // Implementation protected: CClipboardArray m_clipboard; @@ -293,10 +296,11 @@ // mask (filter) CFiltersArray m_afFilters; - // copiees count + // copies count unsigned char m_ucCopies; unsigned char m_ucCurrentCopy; + tstring_t m_strTaskBasePath; // base path at which the files will be stored bool m_bSaved; // has the state been saved ('til next modification) public: @@ -330,7 +334,7 @@ // CLogFile m_log; icpf::log_file m_log; - CCriticalSection m_cs; // protection for this class + mutable CCriticalSection m_cs; // protection for this class }; /////////////////////////////////////////////////////////////////////////// @@ -349,17 +353,17 @@ void SetSize( int nNewSize, int nGrowBy = -1 ); CTask* GetAt( int nIndex ); - void SetAt( int nIndex, CTask* newElement ); +// void SetAt( int nIndex, CTask* newElement ); int Add( CTask* newElement ); void RemoveAt( int nIndex, int nCount = 1 ); void RemoveAll(); void RemoveAllFinished(); void RemoveFinished(CTask** pSelTask); - void SaveData(LPCTSTR lpszDirectory); - void SaveProgress(LPCTSTR lpszDirectory); - void LoadDataProgress(LPCTSTR lpszDirectory); + void SaveData(); + void SaveProgress(); + void LoadDataProgress(); void TasksBeginProcessing(); void TasksPauseProcessing(); @@ -378,8 +382,11 @@ bool IsFinished(); + void SetTasksDir(const tchar_t* pszPath) { m_strTasksDir = pszPath; } + public: __int64 m_uhRange, m_uhPosition; + tstring_t m_strTasksDir; UINT m_uiOperationsPending; // count of current operations LONG m_lFinished; // count of finished tasks Index: src/ch/ch.cpp =================================================================== diff -u -rb6b8ac5b0a1ab85b4ac788e5429be860d2f20bd5 -rf6c4389122d92e5f84a509e9be0facebac429151 --- src/ch/ch.cpp (.../ch.cpp) (revision b6b8ac5b0a1ab85b4ac788e5429be860d2f20bd5) +++ src/ch/ch.cpp (.../ch.cpp) (revision f6c4389122d92e5f84a509e9be0facebac429151) @@ -118,7 +118,7 @@ return &theApp.m_resManager; } -icpf::config* GetConfig() +chcore::engine_config* GetConfig() { return &theApp.m_cfgSettings; } @@ -247,6 +247,8 @@ } } + // set working dir for the engine + m_cfgSettings.set_base_path(strPath); // register all properties RegisterProperties(&m_cfgSettings); Index: src/ch/ch.h =================================================================== diff -u -rd2b121c78f510b5384b8ef0ca80afbfd7f77fef7 -rf6c4389122d92e5f84a509e9be0facebac429151 --- src/ch/ch.h (.../ch.h) (revision d2b121c78f510b5384b8ef0ca80afbfd7f77fef7) +++ src/ch/ch.h (.../ch.h) (revision f6c4389122d92e5f84a509e9be0facebac429151) @@ -28,8 +28,9 @@ #include "CfgProperties.h" //#include "LogFile.h" #include "../libicpf/log.h" -#include "../libicpf/cfg.h" +#include "../libchcore/EngineCfg.h" #include "../libictranslate/ResourceManager.h" + using namespace std; ///////////////////////////////////////////////////////////////////////////// @@ -59,7 +60,7 @@ friend int MsgBox(UINT uiID, UINT nType=MB_OK, UINT nIDHelp=0); friend CCopyHandlerApp* GetApp(); friend ictranslate::CResourceManager* GetResManager(); - friend icpf::config* GetConfig(); + friend chcore::engine_config* GetConfig(); // friend CLogFile* GetLog(); void OnConfigNotify(uint_t uiPropID); @@ -71,7 +72,7 @@ public: ictranslate::CResourceManager m_resManager; // CConfigManager m_cfgManager; - icpf::config m_cfgSettings; + chcore::engine_config m_cfgSettings; icpf::log_file m_lfLog; CWnd *m_pMainWindow;