bool CHooks::Save() { CString strhooks; for (hookiterator it = begin(); it != end(); ++it) { strhooks += GetHookTypeString(it->first.htype); strhooks += '\n'; strhooks += it->first.path.GetWinPathString(); strhooks += '\n'; strhooks += it->second.commandline; strhooks += '\n'; strhooks += (it->second.bWait ? L"true" : L"false"); strhooks += '\n'; strhooks += (it->second.bShow ? L"show" : L"hide"); strhooks += '\n'; strhooks += (it->second.bEnforce ? L"enforce" : L"ask"); strhooks += '\n'; } CRegString reghooks(L"Software\\TortoiseSVN\\hooks"); reghooks = strhooks; if (reghooks.GetLastError() != ERROR_SUCCESS) return false; return true; }
bool CHooks::Save() { CString strhooks; for (hookiterator it = begin(); it != end(); ++it) { strhooks += GetHookTypeString(it->first.htype); strhooks += '\n'; strhooks += it->first.path.GetWinPathString(); strhooks += '\n'; strhooks += it->second.commandline; strhooks += '\n'; strhooks += (it->second.bWait ? _T("true") : _T("false")); strhooks += '\n'; strhooks += (it->second.bShow ? _T("show") : _T("hide")); strhooks += '\n'; } CRegString reghooks(_T("Software\\TortoiseGit\\hooks")); reghooks = strhooks; if (reghooks.GetLastError()) return false; return true; }
bool CHooks::Create() { if (m_pInstance == NULL) m_pInstance = new CHooks(); CRegString reghooks(_T("Software\\TortoiseGit\\hooks")); CString strhooks = reghooks; // now fill the map with all the hooks defined in the string // the string consists of multiple lines, where one hook script is defined // as four lines: // line 1: the hook type // line 2: path to working copy where to apply the hook script // line 3: command line to execute // line 4: 'true' or 'false' for waiting for the script to finish // line 5: 'show' or 'hide' on how to start the hook script hookkey key; int pos = 0; hookcmd cmd; while ((pos = strhooks.Find('\n')) >= 0) { // line 1 key.htype = GetHookType(strhooks.Mid(0, pos)); if (pos+1 < strhooks.GetLength()) strhooks = strhooks.Mid(pos+1); else strhooks.Empty(); bool bComplete = false; if ((pos = strhooks.Find('\n')) >= 0) { // line 2 key.path = CTGitPath(strhooks.Mid(0, pos)); if (pos+1 < strhooks.GetLength()) strhooks = strhooks.Mid(pos+1); else strhooks.Empty(); if ((pos = strhooks.Find('\n')) >= 0) { // line 3 cmd.commandline = strhooks.Mid(0, pos); if (pos+1 < strhooks.GetLength()) strhooks = strhooks.Mid(pos+1); else strhooks.Empty(); if ((pos = strhooks.Find('\n')) >= 0) { // line 4 cmd.bWait = (strhooks.Mid(0, pos).CompareNoCase(_T("true"))==0); if (pos+1 < strhooks.GetLength()) strhooks = strhooks.Mid(pos+1); else strhooks.Empty(); if ((pos = strhooks.Find('\n')) >= 0) { // line 5 cmd.bShow = (strhooks.Mid(0, pos).CompareNoCase(_T("show"))==0); if (pos+1 < strhooks.GetLength()) strhooks = strhooks.Mid(pos+1); else strhooks.Empty(); bComplete = true; } } } } if (bComplete) { m_pInstance->insert(std::pair<hookkey, hookcmd>(key, cmd)); } } return true; }