void MDiffWindow::ChooseFile(int inFileNr) { string currentFolder = gApp->GetCurrentFolder(); MFile url; if (inFileNr == 1) { if (mDoc1 != nil) url = mDoc1->GetFile(); else if (mDir1Inited) url = mDir1; } else if (inFileNr == 2) { if (mDoc2 != nil) url = mDoc2->GetFile(); else if (mDir2Inited) url = mDir2; } try { uint32 modifiers = GetModifiers(); if (modifiers != 0) { fs::path dir = url.GetPath(); if (ChooseDirectory(dir) and fs::is_directory(dir)) SetDirectory(inFileNr, dir); else gApp->SetCurrentFolder(currentFolder); } else if (ChooseOneFile(url)) { MTextDocument* doc = dynamic_cast<MTextDocument*>( gApp->OpenOneDocument(url)); if (doc != nil) SetDocument(inFileNr, doc); } else gApp->SetCurrentFolder(currentFolder); } catch (...) { gApp->SetCurrentFolder(currentFolder); throw; } }
void MMessageList::AddMessage( MMessageKind inKind, const MFile& inFile, uint32 inLine, uint32 inMinOffset, uint32 inMaxOffset, const string& inMessage) { uint32 fileNr = 0; if (inFile.IsLocal() == false or fs::exists(inFile.GetPath())) { MFileTable::iterator f = find(mImpl->mFileTable.begin(), mImpl->mFileTable.end(), inFile); if (f == mImpl->mFileTable.end()) f = mImpl->mFileTable.insert(f, inFile); fileNr = f - mImpl->mFileTable.begin() + 1; } mImpl->mArray.push_back(MMessageItem::Create(inKind, fileNr, inLine, inMinOffset, inMaxOffset, inMessage)); }
void MDiffWindow::RecalculateDiffsForDirs( const MFile& inDirA, const MFile& inDirB) { vector<fs::path> a, b; fs::path p; int flags = 0; if (mRecursive) flags = kFileIter_ReturnDirectories; MFileIterator iter_a(inDirA.GetPath(), flags); while (iter_a.Next(p)) a.push_back(p); MFileIterator iter_b(inDirB.GetPath(), flags); while (iter_b.Next(p)) b.push_back(p); sort(a.begin(), a.end()); sort(b.begin(), b.end()); vector<fs::path>::iterator ai, bi; ai = a.begin(); bi = b.begin(); while (ai != a.end() and bi != b.end()) { if (ai->leaf() == bi->leaf()) { if (not FileNameMatches(mIgnoreFileNameFilter.c_str(), *ai)) { if (is_directory(*ai) and is_directory(*bi)) { if (mRecursive) RecalculateDiffsForDirs(MFile(*ai), MFile(*bi)); } else if (is_directory(*ai) or is_directory(*bi) or FilesDiffer(MFile(*ai), MFile(*bi))) AddDirDiff(relative_path(mDir1, *ai).string(), 0); } ++ai; ++bi; } else { if (ai->leaf() < bi->leaf()) { if (not FileNameMatches(mIgnoreFileNameFilter.c_str(), *ai)) AddDirDiff(relative_path(mDir1, *ai).string(), 1); ++ai; } else { if (not FileNameMatches(mIgnoreFileNameFilter.c_str(), *bi)) AddDirDiff(relative_path(mDir2, *bi).string(), 2); ++bi; } } } while (ai != a.end()) { if (not FileNameMatches(mIgnoreFileNameFilter.c_str(), *ai)) AddDirDiff(relative_path(mDir1, *ai).string(), 1); ++ai; } while (bi != b.end()) { if (not FileNameMatches(mIgnoreFileNameFilter.c_str(), *bi)) AddDirDiff(relative_path(mDir2, *bi).string(), 2); ++bi; } }