/** * @brief Display file encoding dialog to user & handle user's choices */ bool CMergeDoc::DoFileEncodingDialog() { if (!PromptAndSaveIfNeeded(true)) return false; CLoadSaveCodepageDlg dlg(m_nBuffers); dlg.EnableSaveCodepage(true); dlg.SetCodepages(m_ptBuf[0]->getCodepage()); if (IDOK != dlg.DoModal()) return false; bool doLeft = dlg.DoesAffectLeft(); bool doMiddle = dlg.DoesAffectMiddle(); bool doRight = dlg.DoesAffectRight(); FileLocation fileloc[3]; bool bRO[3]; for (int pane = 0; pane < m_nBuffers; pane++) { bRO[pane] = m_ptBuf[pane]->GetReadOnly(); if ((pane == 0 && doLeft) || (pane == 1 && doRight && m_nBuffers < 3) || (pane == 1 && doMiddle && m_nBuffers == 3) || (pane == 2 && doRight && m_nBuffers == 3)) { fileloc[pane].encoding.m_unicoding = ucr::NONE; fileloc[pane].encoding.m_codepage = dlg.GetLoadCodepage(); } else { fileloc[pane].encoding.m_unicoding = m_ptBuf[pane]->getUnicoding(); fileloc[pane].encoding.m_codepage = m_ptBuf[pane]->getCodepage(); } fileloc[pane].setPath(m_filePaths[pane]); } OpenDocs(m_nBuffers, fileloc, bRO, m_strDesc); if (dlg.GetSaveCodepage() != dlg.GetLoadCodepage()) { int nSaveCodepage = dlg.GetSaveCodepage(); for (int pane = 0; pane < m_nBuffers; pane++) { bRO[pane] = m_ptBuf[pane]->GetReadOnly(); if (!bRO[pane] && ( (pane == 0 && doLeft) || (pane == 1 && doRight && m_nBuffers < 3) || (pane == 1 && doMiddle && m_nBuffers == 3) || (pane == 2 && doRight && m_nBuffers == 3) )) { m_ptBuf[pane]->setCodepage(nSaveCodepage); m_ptBuf[pane]->SetModified(); UpdateHeaderPath(pane); } } } return true; }
/** * @brief Load one file */ HRESULT CHexMergeDoc::LoadOneFile(int index, LPCTSTR filename, BOOL readOnly) { if (Try(m_pView[index]->LoadFile(filename), MB_ICONSTOP) != 0) return E_FAIL; m_pView[index]->SetReadOnly(readOnly); m_filePaths.SetPath(index, filename); ASSERT(m_nBufferType[index] == BUFFER_NORMAL); // should have been initialized to BUFFER_NORMAL in constructor String strDesc = GetMainFrame()->m_strDescriptions[index]; if (!strDesc.empty()) { m_strDesc[index] = strDesc; m_nBufferType[index] = BUFFER_NORMAL_NAMED; } UpdateHeaderPath(index); m_pView[index]->ResizeWindow(); return S_OK; }
/** * @brief Perform directory comparison again from scratch */ void CDirDoc::Rescan() { if (!m_pCtxt) return; CDirFrame *pf = m_pDirView->GetParentFrame(); // If we're already doing a rescan, bail out UINT threadState = m_diffThread.GetThreadState(); if (threadState == CDiffThread::THREAD_COMPARING) return; m_statusCursor = new CustomStatusCursor(0, IDC_APPSTARTING, IDS_STATUS_RESCANNING); GetLog()->Write(CLogFile::LNOTICE, _T("Starting directory scan:\n\tLeft: %s\n\tRight: %s\n"), m_pCtxt->GetLeftPath().c_str(), m_pCtxt->GetRightPath().c_str()); m_pCompareStats->Reset(); m_pDirView->StartCompare(m_pCompareStats); // Don't clear if only scanning selected items if (!m_bMarkedRescan) { m_pDirView->DeleteAllDisplayItems(); m_pCtxt->RemoveAll(); } LoadLineFilterList(); DIFFOPTIONS options = {0}; options.nIgnoreWhitespace = GetOptionsMgr()->GetInt(OPT_CMP_IGNORE_WHITESPACE); options.bIgnoreBlankLines = GetOptionsMgr()->GetBool(OPT_CMP_IGNORE_BLANKLINES); options.bFilterCommentsLines = GetOptionsMgr()->GetBool(OPT_CMP_FILTER_COMMENTLINES); options.bIgnoreCase = GetOptionsMgr()->GetBool(OPT_CMP_IGNORE_CASE); options.bIgnoreEol = GetOptionsMgr()->GetBool(OPT_CMP_IGNORE_EOL); m_pCtxt->CreateCompareOptions(options); m_pCtxt->m_bGuessEncoding = GetOptionsMgr()->GetBool(OPT_CP_DETECT); m_pCtxt->m_bIgnoreSmallTimeDiff = GetOptionsMgr()->GetBool(OPT_IGNORE_SMALL_FILETIME); m_pCtxt->m_bStopAfterFirstDiff = GetOptionsMgr()->GetBool(OPT_CMP_STOP_AFTER_FIRST); m_pCtxt->m_nQuickCompareLimit = GetOptionsMgr()->GetInt(OPT_CMP_QUICK_LIMIT); m_pCtxt->m_bPluginsEnabled = GetOptionsMgr()->GetBool(OPT_PLUGINS_ENABLED); m_pCtxt->m_bWalkUniques = GetOptionsMgr()->GetBool(OPT_CMP_WALK_UNIQUE_DIRS); m_pCtxt->m_pCompareStats = m_pCompareStats; m_pCtxt->m_bRecursive = !!m_bRecursive; // Set total items count since we don't collect items if (m_bMarkedRescan) m_pCompareStats->IncreaseTotalItems(m_pDirView->GetSelectedCount()); UpdateHeaderPath(0); UpdateHeaderPath(1); // draw the headers as active ones pf->GetHeaderInterface()->SetActive(0, TRUE); pf->GetHeaderInterface()->SetActive(1, TRUE); // Make sure filters are up-to-date theApp.m_globalFileFilter.ReloadUpdatedFilters(); m_pCtxt->m_piFilterGlobal = &theApp.m_globalFileFilter; // Show active filter name in statusbar pf->SetFilterStatusDisplay(theApp.m_globalFileFilter.GetFilterNameOrMask().c_str()); // Folder names to compare are in the compare context m_diffThread.SetContext(m_pCtxt); m_diffThread.SetHwnd(m_pDirView->GetSafeHwnd()); m_diffThread.SetMessageIDs(MSG_UI_UPDATE); m_diffThread.SetCompareSelected(!!m_bMarkedRescan); m_diffThread.CompareDirectories(m_pCtxt->GetNormalizedLeft(), m_pCtxt->GetNormalizedRight()); m_bMarkedRescan = FALSE; }