Пример #1
0
void wxCrafterTab::BuildTree()
{
    m_treeCtrl->Freeze();
    m_treeCtrl->DeleteAllItems();
    
    m_treeCtrl->AddRoot(_("Hidden Root"));
    
    // Load all wxcp files
    FilesList allWxcpFiles;
    wxcHelper::GetAllFiles( allWxcpFiles, wxT("wxcp") );
    
    // Now add the file to the tab view
    FilesList::iterator iter = allWxcpFiles.begin();
    for(; iter != allWxcpFiles.end(); ++iter ) {
        wxFileName fnProjectFile( (*iter)->GetParentProject()->GetFilename() );
        wxFileName fnResrouceFile( (*iter)->file );
        wxTreeItemId projectItem = GetProjectNode( (*iter)->GetParentProject()->GetTitle() );
        if ( !projectItem.IsOk() ) {
            // First time, add a project node
            projectItem = m_treeCtrl->AppendItem(m_treeCtrl->GetRootItem(), (*iter)->GetParentProject()->GetTitle(), 1, 1, new wxCrafterTabItemData(wxCrafterTabItemData::kKindProject));
        }
        wxCrafterTabItemData* itemData = new wxCrafterTabItemData(fnResrouceFile.GetFullPath());
        
        fnResrouceFile.MakeRelativeTo( fnProjectFile.GetPath() );
        m_treeCtrl->AppendItem(projectItem, fnResrouceFile.GetFullPath(), 0, 0, itemData);
    }
    m_treeCtrl->ExpandAll();
    m_treeCtrl->Thaw();
}
Пример #2
0
	void Process()
	{
		PathListIt it = paths.begin();
		while (it != paths.end()) {
			getFolderContent(*it);
			++it;
		}
		logInfo(L"Files to process:\t%8llu\n", data.size());

		logDebug(L"");
		std::sort(data.begin(), data.end(), CompareBySizeAndTime);
		std::pair<FilesListIt, FilesListIt> bounds;
		FilesListIt srch = data.begin();
		while (srch != data.end()) {
			logCounter(L"Files left:\t%8llu", std::distance(srch, data.end()));
			bounds = std::equal_range(srch, data.end(), *srch, CompareBySize);
			if (std::distance(bounds.first, bounds.second) == 1) {
				++Statistics::getInstance()->filesFoundUnique;
				data.erase(bounds.first);
			} else {
				while (srch != bounds.second) {
					FilesListIt it = srch;
					++it;
					shared_ptr<File>& f1 = *srch;
					while (it != bounds.second) {
						shared_ptr<File>& f2 = *it;
						AutoUTF buf1(f1->path());
						AutoUTF buf2(f2->path());
						{
							ConsoleColor col(FOREGROUND_INTENSITY | FOREGROUND_BLUE | FOREGROUND_GREEN);
							logDebug(L"Comparing files [size = %I64u]:\n", f1->size());
						}
						logDebug(L"  %s\n", buf1.c_str());
						logDebug(L"  %s\n", buf2.c_str());
						++Statistics::getInstance()->fileCompares;
						f1->refresh();
						f2->refresh();
						if (AttrMustMatch && f1->attr() != f2->attr()) {
							{
								ConsoleColor col(FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN);
								logDebug(L"  Attributes of files do not match, skipping\n");
							}
							Statistics::getInstance()->fileMetaDataMismatch++;
							++it;
							break;
						}
						if (TimeMustMatch && f1->mtime() != f2->mtime()) {
							{
								ConsoleColor col(FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN);
								logDebug(L"  Modification timestamps of files do not match, skipping\n");
							}
							Statistics::getInstance()->fileMetaDataMismatch++;
							++it;
							break;
						}
						if (!isSameVolume(*f1, *f2)) {
							{
								ConsoleColor col(FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN);
								logDebug(L"  Files ignored - on different volumes\n");
							}
							++Statistics::getInstance()->filesOnDifferentVolumes;
							++it;
							break;
						}
						if (f1 == f2) {
							++Statistics::getInstance()->fileAlreadyLinked;
							{
								ConsoleColor col(FOREGROUND_INTENSITY | FOREGROUND_GREEN);
								logDebug(L"  Files ignored - already linked\n");
							}
							++it;
							break;
						}
						if (f1->size() > FirstBlock) {
							if (!f1->LoadHashMini()) {
								break;
							}
							if (!f2->LoadHashMini()) {
								it = data.erase(it);
								continue;
							}
						} else {
							if (!f1->LoadHashFull()) {
								break;
							}
							if (!f2->LoadHashFull()) {
								it = data.erase(it);
								continue;
							}
						}
						if (isIdentical(*f1, *f2)) {
							++Statistics::getInstance()->fileContentSame;
							if (logLevel == LOG_VERBOSE) {
								{
									ConsoleColor col(FOREGROUND_INTENSITY | FOREGROUND_BLUE | FOREGROUND_GREEN);
									logVerbose(L"Comparing files [size = %I64u]:\n", f1->size());
								}
								logVerbose(L"  %s\n", buf1.c_str());
								logVerbose(L"  %s\n", buf2.c_str());
							}
							{
								ConsoleColor col(FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN);
								logVerbose(L"  Files are equal, hard link possible\n");
							}
							if (hardlink) {
								f1->hardlink(*f2);
							}
							Statistics::getInstance()->FreeSpaceIncrease += f1->size();
							it = data.erase(it);
						} else {
							{
								ConsoleColor col(FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN);
								logDebug(L"  Files differ in content (hash)\n");
							}
							Statistics::getInstance()->hashComparesHit1++;
							++it;
						}
					}
					srch = data.erase(srch);
				}
			}
			srch = bounds.second;
		}
		logCounter(L"                              ");
	}